We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 74abf06 commit 95bdf5aCopy full SHA for 95bdf5a
leetcode.com 17. Letter Combinations of a Phone Number v2/main.py
@@ -13,21 +13,15 @@ def letterCombinations(self, digits: str) -> List[str]:
13
dict['8'] = ['t', 'u', 'v']
14
dict['9'] = ['w', 'x', 'y', 'z']
15
16
- queue = [['']]
+ queue = ['']
17
queue2 = []
18
19
for d in digits:
20
for prev in queue:
21
for new in dict[d]:
22
- queue2.append(prev + [new])
+ queue2.append(prev + new)
23
24
queue = queue2
25
26
27
- answer = []
28
- for q in queue:
29
- a = ''.join(q)
30
- if a != '':
31
- answer.append(a)
32
-
33
- return answer
+ return list(filter(lambda a: len(a) > 0, queue))
0 commit comments