Created
July 24, 2018 07:38
-
-
Save luojiyin1987/3bf54b6202c7cf323d69f1907e9dcd1f to your computer and use it in GitHub Desktop.
Letter Case Permutation
This file contains hidden or 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): | |
| """ | |
| :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