Letter Case Permutation

Given a string s, return all possible strings we can make by changing each letter case independently. Pattern focus: Bitmask Enumeration. Each alphabetic character can be toggled like a bit choice, while digits remain fixed.

Input Format

s = alphanumeric string

Output Format

all case permutations of s

Constraints

  • 1 <= input size <= 10^5
  • -10^9 <= numeric values <= 10^9
  • s must satisfy the format described in inputFormat.

Examples

Example 1:

Input:

s = "a1b2"

Output:

["a1b2","a1B2","A1b2","A1B2"]

Explanation:

Each letter can be uppercase or lowercase independently.

Example 2:

Input:

s = "3z4"

Output:

["3z4","3Z4"]

Explanation:

Only the letter z changes case.

Loading...
Letter Case Permutation - Bit Manipulation