Hard

Quiz

#132 Palindrome Partitioning II

APPROACH

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
1 of 4
1:00

What is the optimal approach for this problem?