时间0 ms
击败
100%
内存9.8 MB
击败
83.79%
class Solution {
public:
vector<string> letterCasePermutation(string s) {
vector<string> ans;
function<void(int)> dfs = [&](int i) {
if (i >= s.size()) {
ans.emplace_back(s);
return;
}
dfs(i + 1);
if (s[i] >= 'A') {
s[i] ^= 32;
dfs(i + 1);
}
};
dfs(0);
return ans;
}
};