Back to DSA

Palindrome Partitioning

hard
Acceptance: 42%
BacktrackingStrings

Given a string, split it into segments where every segment reads the same forwards and backwards (i.e., each segment is a palindrome). Return all such ways to partition the string.

Examples

Example 1:
Input:s = "abba"
Output:[["a","b","b","a"],["a","bb","a"],["abba"]]
Example 2:
Input:s = "x"
Output:[["x"]]

Hints

00:00
1234567