784. 字母大小写全排列

class Solution {
public:
    vector<string>res;
    void dfs(string s, int startIndex, string temp){
        if(startIndex>=s.length()){
            res.push_back(temp);
            return;
        }
        char c = s[startIndex];
        if(isdigit(c)) dfs(s, startIndex+1, temp+c);
        else{
            dfs(s, startIndex+1, temp+c);
            c^=32;
            dfs(s, startIndex+1, temp+c);
        }
    }
    vector<string> letterCasePermutation(string s) {
        dfs(s,0,"");
        return res;
    }
};

你可能感兴趣的:(LeetCode,算法,数据结构,深度优先)