Problem
Given a string s
, partition s
such that every substring of the partition is a palindrome.
Return all possible palindrome partitioning of s
.
Example:
1 |
|
Explanation
- First create a function to check whether a string is palindrome.
- We can use backtracking to find all combination, if a substring is palindrome, then we start from the next character of the substring and check. For example, “abac”, when we check “aba” is a palindrome, then we check start from “c”.
Solution
1 |
|