Given a lowercase string s, you may cut it into pieces such that every
piece is a palindrome. Find the minimum number of cuts needed (a string that
is already a palindrome needs 0 cuts).
A single line: the string s (1 ≤ |s| ≤ 2000, lowercase letters only)
A single integer: the minimum number of cuts.
Input:
aab
Output:
1
Explanation: cut into aa and b.
Case 1
aab
1
Case 2
a
0
Input
aab
Expected Output
1
Run or submit your code to see output here.