-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0784.cpp
More file actions
21 lines (21 loc) · 817 Bytes
/
0784.cpp
File metadata and controls
21 lines (21 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class Solution {
private:
void pushPermutations(vector<string> &permutations, string current, string const &s) {
int currLength = current.length();
if (currLength == s.size()) {
permutations.push_back(current);
return;
}
if (s[currLength] != tolower(s[currLength]))
pushPermutations(permutations, current + (char) tolower(s[currLength]), s);
else if (s[currLength] != toupper(s[currLength]))
pushPermutations(permutations, current + (char) toupper(s[currLength]), s);
pushPermutations(permutations, current + s[currLength], s);
}
public:
vector<string> letterCasePermutation(string s) {
vector<string> permutations;
pushPermutations(permutations, "", s);
return permutations;
}
};