Skip to content

Instantly share code, notes, and snippets.

@luojiyin1987
Created July 24, 2018 07:38
Show Gist options
  • Save luojiyin1987/3bf54b6202c7cf323d69f1907e9dcd1f to your computer and use it in GitHub Desktop.
Save luojiyin1987/3bf54b6202c7cf323d69f1907e9dcd1f to your computer and use it in GitHub Desktop.
Letter Case Permutation
class Solution:
def letterCasePermutation(self, S):
"""
:type S: str
:rtype: List[str]
"""
if not S: return [S]
rest = self.letterCasePermutation(S[1:])
if S[0].isalpha():
return [S[0].lower() + s for s in rest] + [S[0].upper() + s for s in rest]
return [S[0] + s for s in rest]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment