码迷,mamicode.com
首页 > 编程语言 > 详细

leetcode Letter Combinations of a Phone Number python

时间:2015-11-21 00:39:29      阅读:317      评论:0      收藏:0      [点我收藏+]

标签:

class Solution(object):
    def letterCombinations(self, digits):
        """
        :type digits: str
        :rtype: List[str]
        """
        if len(digits) <= 0:
            return list()
        alpha = ["","1","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"]
        res=[]
        word=[]
        def dfs(cur):
            if cur >= len(digits):
                res.append(‘‘.join(word))
            else:
                for x in alpha[int(digits[cur])-(int)(0)]:
                    word.append(x)
                    dfs(cur+1)
                    word.pop()
        dfs(0)
        
        return res

@link http://blog.csdn.net/hcbbt/article/details/44061179

leetcode Letter Combinations of a Phone Number python

标签:

原文地址:http://www.cnblogs.com/allenhaozi/p/4982715.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!