leetcode Letter Combinations of a Phone Number python
2015-11-21 00:00
751 查看
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
相关文章推荐
- Python读取配置文件
- python进阶 内置函数
- 根据输入显示一个人的出生日期(我的第二个python程序)
- python学习笔记-Day04-第三部分(内置函数,map,filter,reduce,yield)
- python学习笔记-Day04-第二部分(lambda表达式)
- python学习笔记(5)
- python学习笔记-Day04-第一部分(冒泡算法的实现)
- python学习笔记(4)
- Python 的判断语句以及输入语句的使用
- pyspark 使用 Ipython
- <LeetCode><Medium>2 Add Two Numbers
- python 写HTML,pyh模块介绍
- Python 入门知识捡漏
- python学习笔记(3)
- Python 内置模块turtle模块的使用
- 5.1.3 date对象
- python实现爬虫统计学校BBS男女比例(二)多线程爬虫
- python学习笔记(2)
- python中input和raw_input有什么区别
- 冰与火之歌:Python的三元表达式