题目来源
题目描述
![在这里插入图片描述](https://img-blog.csdnimg.cn/08c51d222d9d4fa898a4a6c5895362cf.png)
class Solution {
public:
vector<string> letterCasePermutation(string s) {
}
};
题目解析
![在这里插入图片描述](https://img-blog.csdnimg.cn/a8ae09d47f0849b2935986c93f8eb403.png)
class Solution {
vector<string> ans;
void process(string &s, int idx, string path){
if(idx == s.size()){
ans.push_back(path);
return;
}
char ch = s[idx];
if((ch >= '0' && ch <= '9')){
process(s, idx + 1, path + ch);
}else{
process(s, idx + 1, path + (char)(toupper(ch)));
process(s, idx + 1, path + (char)(tolower(ch)));
}
}
public:
vector<string> letterCasePermutation(string s) {
process(s, 0, "");
return ans;
}
};