Palindrome Partitioning II

Given a string s, partition s such that every substring of the partition is a palindrome.

Return the minimum cuts needed for a palindrome partitioning of s.

Example 1
Inputs = "aab"
Output1
The palindrome partitioning ["aa", "b"] could be produced using 1 cut.
Example 2
Inputs = "a"
Output0
A single-character string is already a palindrome, so no cuts are needed.

Constraints

  • 1 <= s.length <= 2000
  • s consists of lowercase English letters only.

Asked at 10 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate