leetcode之Letter Combinations of a Phone Number
来源:互联网 发布:小米4支持什么网络 编辑:程序博客网 时间:2024/06/09 19:09
这个没什么好说的,就是每个数字代表的字母的排列组合。代码如下:
class Solution(object): def letterCombinations(self, digits): """ :type digits: str :rtype: List[str] """ phonenumber = [[' '], ['*'],['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h','i'], ['j', 'k', 'l'], ['m', 'n', 'o'], ['p', 'q','r', 's'], ['t', 'u', 'v'], ['w', 'x', 'y', 'z']] if len(digits) == 0: return [] elif len(digits) == 1: return phonenumber[int(digits)] else: result = phonenumber[int(digits[0])] for i in range(1, len(digits)): m = [] for j in result: for k in phonenumber[int(digits[i])]: m.append(j + k) result = m return result
0 0
- LeetCode: Letter Combinations of a Phone Number
- LeetCode Letter Combinations of a Phone Number
- LeetCode: Letter Combinations of a Phone Number
- [Leetcode] Letter Combinations of a Phone Number
- [LeetCode] Letter Combinations of a Phone Number
- 【leetcode】Letter Combinations of a Phone Number
- LeetCode: Letter Combinations of a Phone Number
- [LeetCode]Letter Combinations of a Phone Number
- LeetCode-Letter Combinations of a Phone Number
- [LeetCode] Letter Combinations of a Phone Number
- LeetCode - Letter Combinations of a Phone Number
- LeetCode:Letter Combinations of a Phone Number
- LeetCode | Letter Combinations of a Phone Number
- leetcode Letter Combinations of a Phone Number
- Leetcode: Letter Combinations of a Phone Number
- 【leetcode】Letter Combinations of a Phone Number
- [LeetCode] Letter Combinations of a Phone Number
- leetcode: Letter Combinations of a Phone Number
- 属性操作
- WF索引器7
- iOS学习: 系统相机 相册的调用
- Java 八大排序之——简单选择排序
- 小知识积累
- leetcode之Letter Combinations of a Phone Number
- Mac下用Brew安装(切换)的PHP版本
- Magento联表查询产品的Group Price 以及 历史已完成订单的产品的price 的 SQL 语句
- 应用程序结构的LIFT准则
- cmake生成eclipse工程的调试问题
- apache启动报错:the requested operation has failed
- 自考总结——软件开发工具
- 20151017数组计算学生考试成绩
- 1.张龙java web