1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| class Solution { public: vector<string> letterCasePermutation(string S) { vector<string> wjl; permutation(wjl, S, 0); return wjl; } private: void permutation(vector<string>& wjl, string s, int index) { wjl.push_back(s); if(index >= s.size()) return; for(int i = index; i < s.size(); i++) { if (isalpha(s[i])) { s[i] ^= 32; permutation(wjl, s, i + 1); s[i] ^= 32; } } } };
|