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.

30:00

Palindrome Partitioning II
hard
Topics
Companies

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:
Input: {"s":"aab"}
Output: 1
Constraints:
  • 1s.length20001 \leq s.\text{length} \leq 2000

  • s consists of lowercase English letters only.

Input
arr ={"s":"aab"}

Initialize dp[i] = i (worst case: cut before each char)

Input String

a

a

b

DP Array (min cuts to partition s[0..i])

0

[0]

1

[1]

2

[2]
Length: 3
Variables
No variables to display
DepthFunction Call
Stack empty
0/4