Here is my short python solution


  • 0
    W
    def letterCombinations(digits):
            dict = {"1": "*", "2": "abc", "3": "def", "4": "ghi", "5": "jkl",
                       "6": "mno", "7": "pqrs", "8": "tuv", "9": "wxyz", "0": " "}
            if digits == "": return []
            acc = [""]
            for i in digits:
                tmp = []
                for letter in dict[i]:
                    tmp += [s + letter for s in acc]
                acc = tmp
            return acc
    

Log in to reply
 

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