All Possible Combinations
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| void helper(vector<string>& A, vector<string>& res, int p, string& now) { if(p == A.size()) res.push_back(now); else { for(auto& ch : A[p]) { now.push_back(ch); helper(A,res,p+1,now); now.pop_back(); } } }
vector<string> Solution::specialStrings(vector<string> &A) { vector<string> res; string now = ""; for(auto& a : A) sort(begin(a), end(a)); helper(A,res,0, now); return res; }
|