Given A string s, partition s such that every substring of the partition are a palindrome.
Return all possible palindrome partitioning of S.
For example, given s = "AaB", Return
[ ["aa","b"], ["a","a","b"] ]
Difficulty factor:
Medium
Realize
BOOL Ispalindrome (string &s, int II, int JJ) {for (int i = II, j = JJ; I < J; i++,j--) {if (s[i]! = S[j] ) return false; } return true; Vector<vector<string> > partition (String s) {vector<vector<string> > VVS; int i = 0; int j = 0; if (s.size () = = 1) {vector<string> vs; Vs.push_back (s); Vvs.push_back (VS); return VVS; } while (J < S.size ()) {if (Ispalindrome (S, I, j)) {if (j = = S.size ()-1) {Vecto R<string> vs; Vs.push_back (s); Vvs.push_back (VS); } else {vector<vector<string> > VVSTR = partition (S.substr (j+1)); for (int k = 0; k < vvstr.size (); ++k) {Vvstr[k].insert (Vvstr[k].begin (), S.substr (i, j-i+1)); Vvs.push_back (Vvstr[k]); }}} j + +; } return VVS;}
Leetcode131--palindrome Partitioning