Phase 1: How many ways can you slice aab? Classify four arrangements, see which pass.
LC 131 · Palindrome Partitioning

Given a string s, return every way to cut it into pieces where every piece reads the same forward and backward. Each cut splits the remainder into a first piece and a tail; the tail is cut the same way, recursively.

input
output[[a, a, b], [aa, b]]

Every string can trivially be split into single letters — every one-character piece is a palindrome. The interesting question is how many LONGER palindromic pieces hide in the string, and how the splits combine.

Guess before you count

racecar reads the same both ways. So does a. So does aba. Here is a short string — aab. How many ways can you slice it so every piece reads the same forward and backward? Guess first — most people say something like five or six, and the answer surprises them.

Below are the four ways you can cut aab into pieces — any pieces, not just ones that pass the both-ways check. Classify each card ✓ if every piece reads the same both ways, ✗ if at least one piece does not. Then submit.

All ways to slice `aab` — classify each
Valid? / 4
aab
a
ab
aa
b
a
a
b
Pick ✓ or ✗ on every card to submit