Dynamic Programming21 sections · 916 units
Open in Course

LeetCode 132 Palindrome Partitioning II - Problem Statement

LeetCode 132

Given a string s, partition it so every substring is a palindrome. Return the minimum number of cuts needed. For "aab", one cut gives ["aa", "b"], both palindromes. For "a", zero cuts needed.

This combines two smaller tasks: checking if substrings are palindromes, and finding minimum cuts. Precompute isPalin[i][j] in O(n2)O(n^2), then find minimum cuts with DP in O(n2)O(n^2).