<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>

static const auto _ = []() -> int {
    std::ios::sync_with_stdio(false);
    std::cin.sync_with_stdio(false);
    std::cout.sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    return 0;
}();

class Solution {
    void generate_string(std::size_t idx, std::string const& source, std::string curr, std::vector<std::string> &res) const 
    {
        if (idx == source.size()) {
            res.emplace_back(std::move(curr));
            return;
        }
        char curr_c {source[idx]}; 
        if (std::isdigit(curr_c)) {
            curr += curr_c;
            generate_string(idx + 1, source, curr, res);
            return;
        }
        std::string lower_str{curr}, higher_str{curr};
        lower_str += std::tolower(curr_c);
        higher_str += std::toupper(curr_c);
        generate_string(idx + 1, source, lower_str, res);
        generate_string(idx + 1, source, higher_str, res);
    }
public:
    vector<string> letterCasePermutation(string const& s) const noexcept{
        std::vector<std::string> res;
        res.reserve(s.size());
        
        generate_string(0, s, "", res);
        return res;
    }
};
14500