Skip to content
Decoder

Letter Case Permutation

Medium

Problem

Given a string s of letters and digits, you may turn each letter into lower case or upper case independently. Digits stay as they are. Return every string you can make this way, in any order.

Example 1

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

Example 2

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

Example 3

Input
"12345"
Output
["12345"]

Constraints

  • 1 <= s.length <= 12
  • s contains only English letters and digits.

Read it once before you touch anything

Want some pressure? Start the timer. In an interview you get about two minutes to understand the problem.

  1. 1Read the goalWhat goes in, what comes out
  2. 2Scan the examplesCheck one by hand
  3. 3Note the constraintsThey set your Big O
Say what it asks in one sentence
Say it out loud first, then compare with ours.