Skip to content

Create 1312-Minimum-Insertion-Steps-to-Make-a-String-Palindrome.py #4342

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Yatin-aggarwal
Copy link

@Yatin-aggarwal Yatin-aggarwal commented Jul 6, 2025

Description:

This PR adds a solution to LeetCode Problem 1312 using a top-down dynamic programming approach with memoization.The goal is to return the minimum number of insertions required to make the input string a palindrome.

Approach:
We use recursion with memoization (top-down DP) to avoid redundant computations.

The key idea:

If characters at both ends match, move inward.

Else, insert one character and recursively solve for both possible substrings (excluding one character from either end), and take the minimum.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant