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. python基础教程_学习笔记14:标准库:一些最爱——re

    标准库:一些最爱 re re模块包括对正則表達式的支持,由于以前系统学习过正則表達式,所以基础内容略过,直接看python对于正則表達式的支持. 正則表達式的学习,见<Mastering Reg ...

  2. 树形控件CTreeCtrl的使用

    树形控件在界面编程中应用十分普遍,如在资源管理器中和树形结构显示书的文件夹等,我们一步步研究树形控件的使用. 在对话框界面上首先拖动创建一个树,一般我们改变三个属性: Has Buttons显示带有& ...

  3. Asp.Net(C#) MD5 加密

    /// <summary> /// MD5 字符串加密  /// </summary> /// <param name="str">需要加密的字 ...

  4. 关于Console的Main(String[] args)参数输入

    之前接触一个往Console里输入参数的项目,资深QA教我怎么run,灰常脸红. 今日无事,baidu之. Step1 写简单Console Code. class Program { static ...

  5. 前端资料QQ群交流

    转:https://github.com/jsfront/src/blob/master/qq.md 这本来是我QQ群内部的一份公共约定的日常交流规则,后来得到大伙的一致认可,并用实际行动来捍卫它,使 ...

  6. HibernateTemplate 常用方法

    HibernateTemplate 提供非常多的常用方法来完成基本的操作,比如通常的增加.删除.修改.查询等操作,Spring2.0更增加对命名SQL查询的支持,也增加对分页的支 持.大部分情况下,使 ...

  7. Web--->>>Cookie与Session

    1.cookie 1.cookie是存在客户端(浏览器)的进程内存中和客户端所在的机器硬盘上 2.cookie只能能够存储少量文本,大概4K大小 3.cookie是不能在不同浏览器之间共享 3.创建c ...

  8. NSRangeFromString(<#NSString * _Nonnull aString#>) 和rangeOfString

    NSRangeFromString NSString *str1 = @"abcdef"; NSString *str2 = @"1-105"; NSStrin ...

  9. UI事件之unload、resize和scroll

    unload事件 当页面卸载或用户从当前页面换到其他页面上时,会在window上触发unload事件.根据DOM2级规范规定,unload应该在body上触发,但所有浏览器都实现了在window上触发 ...

  10. javascript二级联动

    二级联动在一般的网页中随处可见,一般是地址,比如点击浙江省,随后出现的是杭州市,嘉兴市:点击北京省出现的是朝阳,海淀,而不是出现杭州,嘉兴. 要想实现这个步骤,就要用到javascript来实现.其中 ...