FastPrepMinimum Insertions to Make a Palindrome

Minimum Insertions to Make a Palindrome

Bloomberg LP logoBloomberg LP● HardNEW GRADPHONE SCREEN
Learn

Problem statement

Return the minimum number of single-character insertions needed to turn text into a palindrome. Insertions may occur at any positions.

Function

minInsertionsPalindrome(text: String) → int

Examples

Example 1

text = "apple"return = 3

Three insertions suffice; equivalently, apple has a longest palindromic subsequence of length 2.

Constraints

  • 0 <= text.length <= 2000.
  • The text contains lowercase English letters.

More Bloomberg LP problems

See Bloomberg LP hiring insights
public int minInsertionsPalindrome(String text) {
  // Write your code here.
}
text"apple"
expected3
Checking account…