Letter Case Permutation

IF
AlgoAxiomStaff Engineers
JSTS
Medium20 mins

Given a string s, you can transform every letter individually to be lowercase or uppercase to create another string. Return a list of all possible strings you could create. Return the output in any order.

Examples

Example 1:

Input: s = "a1b2"

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

Explanation: Each letter ('a' and 'b') can independently be uppercase or lowercase.

Example 2:

Input: s = "3z4"

Output: ["3Z4","3z4"]

Explanation: Only 'z' is a letter, so there are two possibilities.

Example 3:

Input: s = "12345"

Output: ["12345"]

Explanation: No letters in the string, so only one possibility.

Constraints

  • 1 <= s.length <= 12
  • s consists of lowercase English letters, uppercase English letters, and digits
Source: Subsets pattern — AlgoAxiom
JavaScript
Test Case 1
root = [1, 2, 3]
Test Case 2
root = [1, 2, 3, 4, 5]
Idle