Palindrome Partitioning II

HardDynamic ProgrammingDynamic Programming

Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.

Practice this as a mock interviewFree to start, no account needed

Problem

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.

Examples

Input: s = "aab"
Output: 1
The palindrome partitioning ["aa","b"] could be produced using 1 cut.
Input: s = "a"
Output: 0
Input: s = "ab"
Output: 1

Constraints

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

What the interviewer grades

A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.

More Dynamic Programming problems