You are viewing a single comment's thread. Return to all comments →
void solveHelper(vector<string> & ans, const string& str, const string& curr, int i) { ans.push_back(curr + str[i]); for (int j = i + 1; j < str.size(); j++) { solveHelper(ans, str, curr + str[i], j); } } vector<string> solve(string s) { vector<string> ans; for (int i = 0; i < s.size(); i++) { solveHelper(ans, s, "", i); } return ans; }
Seems like cookies are disabled on this browser, please enable them to open this website
Building a List
You are viewing a single comment's thread. Return to all comments →
C++ recursive solution