Letter Case Permutation
Given a string S, we can transform every letter individually to be lowercase or uppercase to create another string. Return a list of all possible strings we could create.
Example
Examples:
Input: S = “a1b2”
Output: [“a1b2”, “a1B2”, “A1b2”, “A1B2”]
Solution
class Solution:
def letterCasePermutation(self, S: str) -> List[str]:
alpha = [[i.upper(), i.lower()] if i.isalpha() else i for i in S]
return [''.join(i) for i in itertools.product(*alpha)]