Given a string s, you may change any letter in it to lowercase or uppercase independently. Return a list of every string you can create this way, in any order.
Given a string s, you may change any letter in it to lowercase or uppercase independently. Return a list of every string you can create this way, in any order.
Example 1:
Input: {"s":"a1b2"}
Output: ["a1b2","A1b2","a1B2","A1B2"]
Constraints:
1≤s.length≤12
s consists of lowercase English letters, uppercase English letters, and digits.
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"s":"a1b2"}
"a1b2" has 2 letters. Give each one a switch: bit b of a mask says whether letter b is uppercase. 2 switches give 2^2 = 4 strings.
Each letter is a switch: lower (0) or UPPER (1)
a
bit 0
1
fixed
b
bit 1
2
fixed
Digits never change. Counting the mask from 0 to 3 visits every on/off pattern of the 2 switches exactly once.