<p>Given a string <code>s</code>, you&nbsp;can transform every letter individually to be lowercase or uppercase to create another string.</p>

<p>Return <em>a list of all possible strings we could create</em>. Return the output in <strong>any order</strong>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> s = &quot;a1b2&quot;
<strong>Output:</strong> [&quot;a1b2&quot;,&quot;a1B2&quot;,&quot;A1b2&quot;,&quot;A1B2&quot;]
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> s = &quot;3z4&quot;
<strong>Output:</strong> [&quot;3z4&quot;,&quot;3Z4&quot;]
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= s.length &lt;= 12</code></li>
	<li><code>s</code> consists of lowercase English letters, uppercase English letters, and digits.</li>
</ul>

class Solution {
public:
    // void solve(string &s,int i,vector<string> &res){
    //     if(i==s.length()){
    //         res.push_back(s);
    //         return ;
    //     }
    //     solve(s,i+1,res);
    //     if(isalpha(s[i])){
    //         if(islower(s[i]))
    //             s[i]=toupper(s[i]);
    //         else 
    //             s[i]=tolower(s[i]);
    //         solve(s,i+1,res);
    //         if(isupper(s[i]))
    //             s[i]=tolower(s[i]);
    //         else  s[i]=toupper(s[i]);
    //     }
    // }
    vector<string> letterCasePermutation(string s) {
        //vector<string>res;
       // string ans="";
        //solve(s,0,res);
        //vector<string>d(res.begin(),res.end())
       // return res;
        int n = s.size(); 
        int chars = 0; 
        
        for(int i = 0; i < n; ++i)
        {
            if(s[i] >= 'a' && s[i] <= 'z') ++chars; 
            else if(s[i] >= 'A' && s[i] <= 'z') ++chars; 
        }
        
        vector<string> ans((int)(1 << chars), ""); 
        
        int cnt = 0; 
        for(int i = 0; i < (1 << chars); ++i)
        {
            for(int j = 0, p = 0; j < n; ++j)
            {
                if(s[j] >= 'a' && s[j] <= 'z' || s[j] >= 'A' && s[j] <= 'Z')
                {
                    if(cnt & (1 << p++)) ans[i] += toupper(s[j]); 
                    else ans[i] += tolower(s[j]); 
                }
                else
                { 
                    ans[i] += s[j]; 
                }
            }
            ++cnt; 
        }
        
        return ans;
    }
};
11100