Palindrome Partitioning

medium
Unit 16 · Backtracking0/3 to milestone

Implement:

  • partitions(s): all ways to split s into substrings that are each palindromes, in the order produced by trying shorter first pieces first
  • min_cuts(s): the minimum number of cuts so every piece is a palindrome, in O(n²) using a precomputed palindrome table and a 1-D DP
Pro problem

Unlock this and every premium problem across all tracks — plus hidden-test grading, advanced AI engineering modules and new content every week.

Start 7-day free trial
solution.py · Python 3.13
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Palindrome Partitioning · TechGradify