Given a string s, partition s such that every substring of the partition is a palindrome.
Return all possible palindrome partitioning of s.
For example, given s = "aab"
,
[ ["aa","b"], ["a","a","b"] ] 输出总共2^n种,硬做就可以了
class Solution {public: void sub(vector>&ret,vector >&ISP,vector & one,int start,string& s){ if(start==s.length()){ ret.push_back(one); return; } int size=one.size(); int i=1; while(i+start<=s.length()){ if(ISP[start][i]){ one.push_back(s.substr(start,i)); sub(ret,ISP,one,start+i,s); one.resize(size); } i++; } } bool isPalindrome(string&s,int start,int len){ for(int i=0;i > partition(string s) { vector > ret; if(s=="")return ret; vector > ISP; ISP.resize(s.length()); for(int i=0;i one; sub(ret,ISP,one,0,s); return ret; }};