题目如下:

Python代码:

class Solution(object):
def letterCombinations(self, digits):
"""
:type digits: str
:rtype: List[str]
"""
if not digits:
return []
dic = {'':'abc','':'def','':'ghi','':'jkl','':'mno','':'pqrs','':'tuv','':'wxyz'}
result = []
self.helper(digits,dic,0,"",result)
return result def helper(self,digits,dic,index,temp,result):
if index==len(digits):
result.append(temp)
else:
s = dic[digits[index]]
for i in s:
temp += i
self.helper(digits,dic,index+1,temp,result)
temp = temp[:-1]

LeetCode(17)Letter Combinations of a Phone Number的更多相关文章

  1. LeetCode (17)Letter Combinations of a Phone Number

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

  2. leetcode第18题--Letter Combinations of a Phone Number

    Problem: Given a digit string, return all possible letter combinations that the number could represe ...

  3. LeetCode(17):电话号码的字母组合

    Medium! 题目描述: 给定一个仅包含数字 2-9 的字符串,返回所有它能表示的字母组合. 给出数字到字母的映射如下(与电话按键相同).注意 1 不对应任何字母. 示例: 输入:"23& ...

  4. Leetcode(17)-电话号码的字母组合

    给定一个仅包含数字 2-9 的字符串,返回所有它能表示的字母组合. 给出数字到字母的映射如下(与电话按键相同).注意 1 不对应任何字母. 示例: 输入:"23" 输出:[&quo ...

  5. Leetcode之回溯法专题-17. 电话号码的字母组合(Letter Combinations of a Phone Number)

    [Leetcode]17. 电话号码的字母组合(Letter Combinations of a Phone Number) 题目描述: 给定一个仅包含数字 2-9 的字符串,返回所有它能表示的字母组 ...

  6. 【一天一道LeetCode】#17. Letter Combinations of a Phone Number

    一天一道LeetCode (一)题目 Given a digit string, return all possible letter combinations that the number cou ...

  7. [LeetCode][Python]17: Letter Combinations of a Phone Number

    # -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 17: Letter Combinations of a Phone Numb ...

  8. 《LeetBook》leetcode题解(17):Letter Combinations of a Phone Number[M]

    我现在在做一个叫<leetbook>的免费开源书项目,力求提供最易懂的中文思路,目前把解题思路都同步更新到gitbook上了,需要的同学可以去看看 书的地址:https://hk029.g ...

  9. Leetcode 17. Letter Combinations of a Phone Number(水)

    17. Letter Combinations of a Phone Number Medium Given a string containing digits from 2-9 inclusive ...

随机推荐

  1. MongoDB 学习笔记(一):安装及简单shell操作

    一.说明 1.该系列MongoDB学习笔记的学习环境采用的MongoDB版本为mongodb-win32-i386-2.4.6,操作系统为win7. 二.安装 1.新建两个目录,分别是D:\Insta ...

  2. WTM

    WTM的由来 WalkingTec.Mvvm框架(简称WTM)最早开发与2013年,基于Asp.net MVC3 和 最早的Entity Framework, 当初主要是为了解决公司内部开发效率低,代 ...

  3. [USACO08NOV]奶牛混合起来Mixed Up Cows(状态压缩DP)

    题目描述 Each of Farmer John's N (4 <= N <= 16) cows has a unique serial number S_i (1 <= S_i & ...

  4. django rest-farme-work 的使用(2)

    serialization (序列化) 本测试项目例子地址为: tomchristie/rest-framework-tutorial 开始构建一个新的程序 创建一个新的环境 virtualenv e ...

  5. Python for Xpath

    # Xpath- 在XML文件中查找信息的一套规则/语言,根据XML的元素或者属性进行遍历 ## Xpath开发工具- 开源的Xpath表达式编辑工具:XMLQuire- Chrome插件:Xpath ...

  6. HDU 1757

    简单的矩阵构造题,参看我前几篇的谈到的矩阵的构造法. #include <iostream> #include <cstdio> #include <cstring> ...

  7. nyoj 119 士兵杀敌(三) 【线段树】【单点更新】

    题意:. .. 策略如题. 思路:我们先如果仅仅求某一区间的最大值.我们仅仅须要利用线段树的模板.仅仅须要初始化和询问的时候小小的改动一下.改成祖先结点储存的不再是子节点的和而是两个子节点之间的最大值 ...

  8. xhprof安装&amp;&amp;使用

    听同事说起过一个php性能分析扩展,叫xhprof,近期了解了下. XHProf 是一个轻量级的分层性能測量分析器. 在数据收集阶段.它跟踪调用次数与測量数据,展示程序动态调用的弧线图. 它在报告.后 ...

  9. unity3d教程运行物理机制

    首先,我们将把Hooke定律写Euler方法结合在一起找到新坐标.加速和速度. Hooke定律是F=kx,这里的F是指由水流产生的力(记住,我们将把水体表面模拟为水流),k是指水流的常量.x则是位移. ...

  10. uiautomator中InteractionController学习笔记(8)

    4.1版本号 InteractionController将用户的键盘事件注入到android系统中,与系统进行交互(电视为什么不能设计成可组装,屏幕多大自己决定,想 多大就多大) click(int, ...