Generate every string formed by toggling the letter cases in the input string while leaving digits unchanged.
You are given a string s consisting of letters and digits.
Generate all possible strings that can be formed by independently changing each alphabetic character to either lowercase or uppercase. Digits must remain unchanged.
Return all distinct permutations in any order.
s.s contains only English letters and digits.s in any order.1 <= s.length <= 12s contains only letters and digits.Example 1
Input
s = "a1b2"
Output
["a1b2","a1B2","A1b2","A1B2"]
Explanation
The letters a and b can each be lowercase or uppercase, while digits stay unchanged.
Example 2
Input
s = "3z4"
Output
["3z4","3Z4"]
Explanation
Only z changes case; the digits 3 and 4 remain the same.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.