Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ab13894

Browse files
Create Solution.py
1 parent 6a95077 commit ab13894

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class Solution:
2+
def letterCombinations(self, digits: str) -> List[str]:
3+
map = {'2':"abc", '3':"def", '4':"ghi", '5':"jkl", '6':"mno", '7': "pqrs",
4+
'8':"tuv", '9':"wxyz"}
5+
result = [''] if digits else []
6+
for d in digits:
7+
result = [p + q for p in result for q in map[d]]
8+
return result

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /