#131

Palindrome Partitioning

pupil · 510 · lc medium +27 · verified · 73.7% accepted · 14,202 likes · top 84%

play →

Description

Given a string s, split it into substrings so that every substring is a palindrome. Return all possible such partitionings.

Example 1:

Input: s = "aab"
Output: [["a","a","b"],["aa","b"]]

Example 2:

Input: s = "a"
Output: [["a"]]

Code

1
2
3