As reported: Adobe frontend loop (MTS-2, 2025), round 5 (director round with DSA): a verbal bonus question — the minimum number of cuts for a palindrome partitioning, solved with bottom-up DP and space optimization.
This is LeetCode 132 — Palindrome Partitioning II.
Cut the string s into pieces so that every piece is a palindrome. Return the minimum number of cuts needed.
Example 1
s = "aab"
Output: 1 ("aa" | "b")
Example 2
s = "a"
Output: 0
Example 3
s = "ab"
Output: 1
Constraints: 1 ≤ s.length ≤ 2000; s is lowercase English letters.
Code runner format: one JSON value per line: s. Implement minCut(s); the harness prints the number of cuts.