-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathm784.py
30 lines (23 loc) · 932 Bytes
/
m784.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
class Solution:
def letterCasePermutation(self, s: str) -> List[str]:
s = list(s)
lowercase = 'abcdefghijklmnopqrstuvwxyz'
uppwercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
matches = {lowercase[x]: uppwercase[x] for x in range(len(lowercase))}
matches.update((uppwercase[x], lowercase[x]) for x in range(len(lowercase)))
output = []
currentOutput = []
def helper() -> None :
if len(currentOutput) == len(s) :
output.append(''.join(currentOutput))
return
currentOutput.append(s[len(currentOutput)])
helper()
currentOutput.pop()
if s[len(currentOutput)].isnumeric() :
return
currentOutput.append(matches[s[len(currentOutput)]])
helper()
currentOutput.pop()
helper()
return output