leetcode 016 Letter Combinations of a Phone Number(Python)
来源:互联网 发布:魔法王座神翼升阶数据 编辑:程序博客网 时间:2024/06/05 09:18
Given a digit string, return all possible letter combinations that the number could represent.
Input:Digit string “23”
Output: [“ad”, “ae”, “af”, “bd”, “be”, “bf”, “cd”, “ce”, “cf”].
根据输入的数字输出所有可能的字母组合(按顺序)
深搜水过
class Solution: # @param {string} digits # @return {string[]} def letterCombinations(self,digits): res = [] tel = [] l = len(digits) if l == 0: return [] dic = [' ','','abc','def','ghi','jkl','mno','pqrs','tuv','wxyz'] def dfs(index): if index >= l: res.append(''.join(tel)) return for i in dic[int(digits[index])-0]: print i tel.append(i) dfs(index+1) tel.pop() return dfs(0) return res
0 0
- leetcode 016 Letter Combinations of a Phone Number(Python)
- 【LeetCode with Python】 Letter Combinations of a Phone Number
- 17. Letter Combinations of a Phone Number Leetcode Python
- [leetcode: Python]17. Letter Combinations of a Phone Number
- 【Leetcode】【python】Letter Combinations of a Phone Number
- LeetCode--Letter Combinations of a Phone Number(Python)
- 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
- C语言---整型字符串转换
- C#使用资源字典
- WebRTC学习的方方面面
- 莫队算法小结
- 【NGUI实例开发】实现弹窗面板
- leetcode 016 Letter Combinations of a Phone Number(Python)
- 请实现一个函数,将一个字符串中的空格替换成“%20”。例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy。
- Tiny框架2.0版火热推出
- Word API
- Bash 基础
- c语言输入一个字符串,将其按照相反顺序存入同一个数组
- 白话经典算法系列之五 归并排序的实现
- [bzoj 2654] tree
- Dictionary API