题目:784. 字母大小写全排列
思路:回溯
class Solution {
public:
vector<string> letterCasePermutation(string s) {
vector<string> result;
back(result,s,0);
return result;
}
void back(vector<string>& result, string& s,int index){
if(index == s.size()){
result.emplace_back(s);
return ;
}
if(isdigit(s[index])){
back(result,s,index+1);
}else{
s[index]=tolower(s[index]);
back(result,s,index+1);
s[index]=toupper(s[index]);
back(result,s,index+1);
}
}
};