Palindrome partitioning asks for every way to cut a string into contiguous pieces where each piece is a palindrome — a run of characters that reads the same forwards and backwards, like aa, b, or racecar. This is LeetCode 131. For aab there are exactly two such splits: a | a | b and aa | b. You return them as a list of partitions, where each partition is an array of its pieces in left-to-right order.
palindromePartitioning(s) // string -> array of partitions (each partition an array of palindrome pieces)
palindromePartitioning('aab');
// [['a', 'a', 'b'], ['aa', 'b']]
palindromePartitioning('a');
// [['a']]
palindromePartitioning('aba');
// [['a', 'b', 'a'], ['aba']]
s exactly, with nothing dropped, added, or reordered.palindromePartitioning('') returns [[]]: a single partition that contains no pieces.