标签:last http push code tor pre bsp turn alt
class Solution { public: vector<vector<string>> ans; bool isok(string s){ int i=0; int j=s.size()-1; while(i<j){ if(s[i]!=s[j]){ return false; } i++;j--; } return true; } void backtrack(string s, vector<string> cur,int lastindex){ if(lastindex>=s.size()){ ans.push_back(cur); return; } for(int i=lastindex;i<s.size();i++){ string stemp=s.substr(lastindex,i-lastindex+1); if(isok(stemp)){ cur.push_back(stemp); backtrack(s,cur,i+1); cur.pop_back(); } } } vector<vector<string>> partition(string s) { vector<string> cur; backtrack(s,cur,0); return ans; } };
标签:last http push code tor pre bsp turn alt
原文地址:https://www.cnblogs.com/joelwang/p/11956925.html