Backtracking
LC #131Medium
Palindrome Partitioning
Backtracking
AmazonGoogleMetaProblem
Partition a string such that every substring is a palindrome. Return all possible partitions.
backtrackingdynamic-programmingstring
Constraints
- ›1 ≤ s.length ≤ 16
- ›s consists of lowercase English letters only
Example
Input
s = "aab"Output
[["a","a","b"],["aa","b"]]Why
"a","a","b" all palindromes. "aa" and "b" also palindromes