FreeCareerPath
Build the PrimitiveMedium

Palindrome Partitioning

Write `partition(s)` returning every way to cut the string so that every piece is a palindrome. partition("aab") -> [["a","a","b"], ["aa","b"]] Generating all 2^(n-1) partitions and filtering is the slow answer. Cut only where the prefix is already a palindrome — an invalid prefix kills its entire subtree immediately, which is what backtracking is for.

What to expect: A timer starts when you begin. Edit the starter code, run it against the test suite as many times as you like, then finish when you're done. The reference solution and interviewer follow-up questions unlock only after you finish.

Log in to start this session

Timed sessions and your results for "Palindrome Partitioning" are saved to your account — logging in takes a few seconds.

Palindrome Partitioning — FreeCareerPath