leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
0784.cpp (499B)
0 class Solution {
1 vector<string> res;
3 void rec(string &s, int st, string crnt) {
4 while (st < s.size() && !isalpha(s[st]))
5 crnt += s[st++];
6 if (st == s.size()) {
7 res.push_back(crnt);
8 return;
9 }
11 char c = tolower(s[st]);
12 rec(s, st + 1, crnt + c);
13 rec(s, st + 1, crnt + (char)toupper(c));
14 }
16 public:
17 vector<string> letterCasePermutation(string s) {
18 rec(s, 0, "");
19 return res;
20 }
21 };