cpp
class Solution {
public:
vector<string>path;
vector<vector<string> >ans;
void backtracking(string s,int star){
if(star>=s.size()){
ans.push_back(path);
return;
}
for(int i=star;i<s.size();i++){
if(isp(s,star,i)){
string cnt=s.substr(star,i-star+1);
path.push_back(cnt);
}else continue;
backtracking(s,i+1);
path.pop_back();
}
}
bool isp(string s,int f,int e){
for(int i=f, j=e;i<j;i++,j--){
if(s[i]!=s[j])return false;
}
return true;
}
vector<vector<string>> partition(string s) {
backtracking(s,0);
return ans;
}
};