Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def letterCombinations(self, digits):
- if not digits:
- return []
- dictionario = {
- '2': 'abc',
- '3': 'def',
- '4': 'ghi',
- '5': 'jkl',
- '6': 'mno',
- '7': 'pqrs',
- '8': 'tuv',
- '9': 'wxyz',
- }
- queue = collections.deque()
- queue.append('')
- for char in digits:
- for i in range(len(queue)):
- s = queue.popleft()
- for c in dictionario[char]:
- queue.append(s + c)
- return queue
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement