Python code.. I used dfs when I wrote cpp for this problem

  • 0
    class Solution:
        # @return a list of strings, [s1, s2]
        def letterCombinations(self, digits):
            if digits=='':
                return [""]
            for i in xrange(1,len(digits)):
                comb=[x+y for x in comb for y in letter[digits[i]]]
            return comb

Log in to reply

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