Example 1
Input
palindrome_partitions('aab')
Output
[['a', 'a', 'b'], ['aa', 'b']]
Two ways: split into single letters 'a','a','b' or take 'aa' then 'b'.
Full lesson preview
Compute every way to partition a string so that every substring is a palindrome, using DP pruning to speed recursion.
Problem statement
Task
Examples
Input
palindrome_partitions('aab')
Output
[['a', 'a', 'b'], ['aa', 'b']]
Two ways: split into single letters 'a','a','b' or take 'aa' then 'b'.
Input format
Output format
Constraints
Samples
Input
palindrome_partitions('efe')
Output
[['e', 'f', 'e'], ['efe']]
Either single letters or the whole string 'efe' which is a palindrome.