class Solution {
public:
vector<vector<string>> res;
bool isHuiwen(string s) {
for (int i = 0; i < s.length() / 2; i++) if (s[i] != s[s.length()- 1 - i]) return false;
return true;
}
void helper(string s, vector<string> curres) {
//string backS = s.substr(index);
//if (s.length() == 0) return;
//if (!isHuiwen(frontS)) return;
//if (index > s.length()) return;
for (int i = 1; i <= s.length(); i++) {
string frontS = s.substr(0, i);
if (isHuiwen(frontS)) {
vector<string> nxtres = curres;
nxtres.push_back(frontS);
if(i == s.length()) res.push_back(nxtres);
helper(s.substr(i), nxtres);
}
}
return;
}
vector<vector<string>> partition(string s) {
vector<string> temp = {};
helper(s, temp);
//vector<vector<string>> r(res.begin(), res.end());
return res;
}
};