15% off all plans & roadmaps Use code
See plansLeetCode 1312 · Solution & editorial
Given a string s. In one step you can insert any character at any index of the string.
Minimum Insertion Steps to Make a String Palindrome is a Dynamic Programming (DP) Patterns problem, in the 2D Array (Longest Common Subsequence - LCS) subpattern. The pattern covers fibonacci, Kadane, knapsack, LCS, LIS, edit distance, grid paths, and word break
Find longest common subsequence between two strings using 2D DP.
The reference solution runs in O(n^2) time and O(n) space.
Minimum Insertion Steps to Make a String Palindrome has been reported in interviews at Amazon, LinkedIn.
The full editorial is part of Pro
It explains the core insight, the complexity analysis and the common mistakes, with a worked solution.
Minimum Insertion Steps to Make a String Palindrome is a Dynamic Programming (DP) Patterns problem, in the 2D Array (Longest Common Subsequence - LCS) subpattern. Once the approach above makes sense, write it yourself and then work through the neighbouring problems that reuse it.