Skip to content
Decoder

Palindrome Partitioning

Medium

Problem

Given a string s, split it into pieces so that every piece is a palindrome (reads the same forwards and backwards). Return all possible ways to do this. Each way is a list of the pieces in order. Return the ways in any order.

Example 1

Input
"aab"
Output
[["a", "a", "b"], ["aa", "b"]]

Example 2

Input
"a"
Output
[["a"]]

Constraints

  • 1 <= s.length <= 16
  • s contains only lowercase English letters.

Read it once before you touch anything

Want some pressure? Start the timer. In an interview you get about two minutes to understand the problem.

  1. 1Read the goalWhat goes in, what comes out
  2. 2Scan the examplesCheck one by hand
  3. 3Note the constraintsThey set your Big O
Say what it asks in one sentence
Say it out loud first, then compare with ours.