class Solution(object):
def letterCombinations(self, digits):
"""
:type digits: str
:rtype: List[str]
"""
if len(digits) <= 0:
return list()
alpha = ["","","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)('')]:
word.append(x)
dfs(cur+1)
word.pop()
dfs(0) return res

@link http://blog.csdn.net/hcbbt/article/details/44061179

leetcode Letter Combinations of a Phone Number python的更多相关文章

  1. [LeetCode]Letter Combinations of a Phone Number题解

    Letter Combinations of a Phone Number: Given a digit string, return all possible letter combinations ...

  2. LeetCode: Letter Combinations of a Phone Number 解题报告

    Letter Combinations of a Phone Number Given a digit string, return all possible letter combinations ...

  3. [LeetCode] Letter Combinations of a Phone Number 电话号码的字母组合

    Given a digit string, return all possible letter combinations that the number could represent. A map ...

  4. LeetCode——Letter Combinations of a Phone Number

    Given a digit string, return all possible letter combinations that the number could represent. A map ...

  5. [LeetCode] Letter Combinations of a Phone Number

    Given a digit string, return all possible letter combinations that the number could represent. A map ...

  6. [LeetCode] Letter Combinations of a Phone Number(bfs)

    Given a digit string, return all possible letter combinations that the number could represent. A map ...

  7. LeetCode Letter Combinations of a Phone Number (DFS)

    题意 Given a digit string, return all possible letter combinations that the number could represent. A ...

  8. [LeetCode] Letter Combinations of a Phone Number 回溯

    Given a digit string, return all possible letter combinations that the number could represent. A map ...

  9. LeetCode Letter Combinations of a Phone Number 电话号码组合

    题意:给一个电话号码,要求返回所有在手机上按键的组合,组合必须由键盘上号码的下方的字母组成. 思路:尼玛,一直RE,题意都不说0和1怎么办.DP解决. class Solution { public: ...

随机推荐

  1. 《Effective C++》:条款46-条款47

    条款46请输入转换的时候,需要定义非模板成员函数 条款47请使用traits class表现类型信息 条款46:须要类型转换时请为模板定义非成员函数 条款 24提到过为什么non-member函数才有 ...

  2. ZCTF-ARM64-Re300

    Re300-arm64     是一个64位的ARM程序.使用IDA加载,蹦出来这个框框,就是说IDA6.6还没有对ARM64位的程序实现relocation的分析.     就是由于这个,所以连对l ...

  3. JAVA 和 C# 调用外部.exe文件,传值并等等exe完成,获取返回值

    JAVA- String ykexe = getProperty("ykexe") + " " + tableout; //getproperty(" ...

  4. php预定义常量&变量

    PHP中可以使用预定义常量获取PHP中的信息,常用的预定义常量如下表所示. 常量名 功能  _FILE_ 默认常量,PHP程序文件名 _LINE_ 默认常量,PHP程序行数  PHP_VERSION ...

  5. 蜗牛爱课- iOS中定时器NSTimer使用

    调用一次计时器方法: //不重复,只调用一次.timer运行一次就会自动停止运行 self.locationTimer = [NSTimer  target:self selector: @selec ...

  6. windows下安装NodeJs

    1.官网(//nodejs.org/en/)下载系统匹配的文件 2.双击安装,完成后发现nodejs文件夹下面有npm, 直接用npm安装其他环境既可 3.如果配置了环境变量,直接Win+R后CMD调 ...

  7. hdu 2509 Be the Winner 博弈

    题目链接 有n堆苹果, 对于其中的每一堆的x个苹果, 它是放在一条线上的. 你每次可以对一堆苹果进行操作, 可以取y个, 1<=y<=x. 然后如果你是取的一条线上中间的苹果, 那么这一堆 ...

  8. Linux man 后面的数字含义及作用

    Linux的man很强大,该手册分成很多section,使用man时可以指定不同的section来浏览,各个section意义如下: 1 Executable programs or shell co ...

  9. python---连接MySQL第四页

    python缓存结果集式的cursor可以用来提高性能. 例子: #!conding:utf-8 from mysql.connector import errorcode import mysql. ...

  10. Gentoo Linux 学习笔记1

         Gentoo Linux是一个基于portage进行包管理的Linux发行版,最早版本始于2002年.其官方官网为http://www.gentoo.org 目前,Gentoo Linux已 ...