Ctrl K

Every Case Spelling

Medium
A coupon code is made of English letters and digits. The system ignores case, so the same coupon can be typed in different ways: each letter can be written in lowercase or uppercase, while digits stay unchanged. Return a list of all distinct strings that can be obtained from code by changing the case of its letters. The strings may be returned in any order.
Example 1
code="q7w" → ['q7w', 'q7W', 'Q7W', 'Q7w']

Two letters with two cases each give 4 spellings. The digit 7 stays as it is.

Example 2
code="404" → ['404']

There are no letters, so the only spelling is the string itself.

Example 3
code="Ab" → ['Ab', 'AB', 'aB', 'ab']
Constraints
  • 1 ≤ len(code) ≤ 12
  • code consists of lowercase and uppercase English letters and digits
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsEvery Shorthand of a Word MediumTwo Disjoint Palindromic Picks MediumBinary Strings Without Two Zeros in a Row MediumShortest Unambiguous Shorthand HardBest Word Set From Tiles Hard
loading Python…
Input
code="q7w"
Expected
['q7w', 'q7W', 'Q7W', 'Q7w']

Run checks the first 3 tests in your browser. Submit checks all 102 tests on the server, hidden ones included.