[LeetCode]题解(python):017-Letter Combinations of a Phone Number
2015-09-24 16:05
1021 查看
[b]题目来源:[/b]
https://leetcode.com/problems/letter-combinations-of-a-phone-number/
[b]题意分析:[/b]
这道题是输入一段数字字符digits,在手机上每个数字所对应不同的字符。具体对应如图:
View Code
转载请注明出处:http://www.cnblogs.com/chruny/p/4835631.html
https://leetcode.com/problems/letter-combinations-of-a-phone-number/
[b]题意分析:[/b]
这道题是输入一段数字字符digits,在手机上每个数字所对应不同的字符。具体对应如图:
class Solution(object): def addDigit(self,digit,ans): tmp = [] for element in digit: if len(ans) == 0: tmp.append(element) for s in ans: tmp.append(s + element) return tmp def letterCombinations(self, digits): """ :type digits: str :rtype: List[str] """ ans = [] d = {'0':' ','1':'*','2':'abc','3':'def','4':'ghi','5':'jkl','6':'mno','7':'pqrs','8':'tuv','9':'wxyz'} for element in digits: ans = self.addDigit(d[element],ans) return ans
View Code
转载请注明出处:http://www.cnblogs.com/chruny/p/4835631.html
相关文章推荐
- 【Python】BeautifulSoup文档(windows-pyhton2.7.10)
- python多进程(multiprocessing)
- 零基础学python-19.4 为什么要在意列表解析与序列映射函数map
- 零基础学python-19.4 为什么要在意列表解析与序列映射函数map
- python批量连接mysql
- 八大排序算法的Python实现
- [LeetCode]题解(python):016-3Sum Closest
- python应用之求主析取范式,主合取范式
- Python try/except异常处理机制
- Python--基本文件方法
- python gzip
- 关于使用python Process 参数消除歧义
- Python分析C盘大文件[夹]
- Python 通过print将数据保存到文件中
- Python opencv 调用sift
- sublime配置python运行环境
- 记录python ConfigParser 处理编码问题
- 笨办法学python学习笔记(1~5)
- the basic operation of sequence in python
- Python之分支与循环