Split a string into all possible lists of substrings such that every substring is a palindrome.
Given a string s, return all possible ways to partition it into contiguous substrings so that every substring in the partition is a palindrome.
A partition is represented as a list of strings whose concatenation is exactly s.
You should return every valid partition.
s.1 <= s.length <= 16 is typical for this problem family.s consists of lowercase English letters.Example 1
Input
s = "aab"
Output
[["a","a","b"],["aa","b"]]
Explanation
Both partitions use only palindromic substrings. "a", "aa", and "b" are palindromes.
Example 2
Input
s = "a"
Output
[["a"]]
Explanation
The only partition uses the whole string, which is a palindrome.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.