Palindrome Relay Splits
mediumA word-game referee needs every way to chop a string into consecutive pieces where every piece reads the same forwards and backwards.
Given a lowercase string s, return all ways to partition it into substrings such that each substring is a palindrome. Each partition is a list of the pieces in their original left-to-right order; the order of partitions in your answer doesn't matter.
Example 1
in s = "aab"
out [["a","a","b"], ["aa","b"]]
"aab" itself and "ab" are not palindromes, so these are the only two splits.
Example 2
in s = "x"
out [["x"]]
Constraints
- · 1 <= len(s) <= 12
- · s contains only lowercase English letters
solution.py● loading python…
test results
Hit ▶ Run to test your code against the visible cases.