#132
Palindrome Partitioning II
master · 1790 · lc hard +32 · verified · 36.7% accepted · 5,909 likes · top 14%
Description
Given a string s, partition it so that every substring is a palindrome.
Return the fewest cuts needed to achieve such a partitioning.
Example 1:
Input: s = "aab"
Output: 1
Explanation: The palindrome partitioning ["aa","b"] could be produced using 1 cut.
Example 2:
Input: s = "a"
Output: 0
Example 3:
Input: s = "ab"
Output: 1
Code
1
2
3