Skip to content

Instantly share code, notes, and snippets.

@Desolve
Created January 17, 2021 08:27
Show Gist options
  • Save Desolve/1d4f551f6da272348a1edad6d6a61c26 to your computer and use it in GitHub Desktop.
Save Desolve/1d4f551f6da272348a1edad6d6a61c26 to your computer and use it in GitHub Desktop.
0784 Letter Case Permutation
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