LeetCode-17-Letter-Combinations-of-a-Phone-Number 递归+模拟
来源:互联网 发布:linux运维之道 mobi 编辑:程序博客网 时间:2024/06/04 17:40
class Solution(object): def letterCombinations(self, digits): """ :type digits: str :rtype: List[str] """ ans=[] if digits=="":return ans map={} map['0']=" " map['2']="abc" map['3']="def" map['4']="ghi" map['5']="jkl" map['6']="mno" map['7']="pqrs" map['8']="tuv" map['9']="wxyz" if digits=="0":return "0" if digits=='2':return ["a","b","c"] if digits=='3':return ["d","e","f"] if digits=='4':return ["g","h","i"] if digits=='5':return ["j","k","l"] if digits=='6':return ["m","n","o"] if digits=='7':return ["p","q","r","s"] if digits=='8':return ["t","u","v"] if digits=='9':return ["w","x","y","z"] t=self.letterCombinations(digits[1:]) for i in range(t.__len__()): for j in range(len(map[digits[0]])): ans.append(map[digits[0]][j]+t[i] ) return ans
阅读全文
1 0
- LeetCode-17-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
- android 中给按钮注册事件
- 机器学习第十三课(DBSCAN,密度最大值聚类,谱聚类)
- [中等] Uva OJ 1608 Non-boring sequences
- ThreadLocal的理解
- 解决Invalid 'log4jConfigLocation' parameter: Log4j config file[F:/*路径*/]not found问题
- LeetCode-17-Letter-Combinations-of-a-Phone-Number 递归+模拟
- 反向树状数组 + 离散化 HDU 5372
- 为什么int型的数组用memset不能清零(memset的使用规范)
- jquery ajax springMVC 解决跨域问题
- pycharm中传入命令行参数
- HTTP请求方法
- Android Studio SVN 使用方法
- 考验颜值的奶奶灰,如果你想看你可以看
- HBuilder打包App方法