#784
Letter Case Permutation
pupil · 485 · lc medium +27 · verified · 75.7% accepted · 4,832 likes · top 87%
Description
Given a string s, independently toggle the case of each letter to generate all possible strings. Digits and other characters remain unchanged. Return all distinct strings that can be created, in any order.
Example 1:
Input: s = "a1b2"
Output: ["a1b2","a1B2","A1b2","A1B2"]
Example 2:
Input: s = "3z4"
Output: ["3z4","3Z4"]
Code
1
2
3