2 line python solution


  • 1
    M
    class Solution(object):
        def letterCombinations(self, digits):
            d = {'2':'abc', '3':'def', '4':'ghi', '5':'jkl', '6':'mno', '7':'pqrs', '8':'tuv', '9':'wxyz'}
            return [''.join(i) for i in itertools.product(*(d[k] for k in digits))] if len(digits) > 0 else []
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.