Created
January 17, 2021 08:27
-
-
Save Desolve/1d4f551f6da272348a1edad6d6a61c26 to your computer and use it in GitHub Desktop.
0784 Letter Case Permutation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution: | |
def letterCasePermutation(self, S: str) -> List[str]: | |
res = [] | |
def helper(a, pos): | |
if pos == len(a): | |
res.append(''.join(a)) | |
else: | |
helper(a, pos + 1) | |
if a[pos].isalpha(): | |
a[pos] = a[pos].upper() | |
helper(a, pos + 1) | |
a[pos] = a[pos].lower() | |
a = list(S.lower()) | |
helper(a, 0) | |
return res |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment