Minimum Insertions to Palindrome
Find the minimum number of characters to insert anywhere in S to make it a palindrome.
Input: one line: the string.
Output: the minimum insertions.
Constraints:
- 1 ≤ |S| ≤ 2000
Sample Tests
Input 1
ab
Output 1
1
Input 2
aa
Output 2
0
Input 3
abcba
Output 3
0
Discussion (opens after you solve — no spoilers before)
No comments yet.