LeetCode(17)Letter Combinations of a Phone Number
题目如下:

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的更多相关文章
- LeetCode (17)Letter Combinations of a Phone Number
题目 Given a digit string, return all possible letter combinations that the number could represent. A ...
- leetcode第18题--Letter Combinations of a Phone Number
Problem: Given a digit string, return all possible letter combinations that the number could represe ...
- LeetCode(17):电话号码的字母组合
Medium! 题目描述: 给定一个仅包含数字 2-9 的字符串,返回所有它能表示的字母组合. 给出数字到字母的映射如下(与电话按键相同).注意 1 不对应任何字母. 示例: 输入:"23& ...
- Leetcode(17)-电话号码的字母组合
给定一个仅包含数字 2-9 的字符串,返回所有它能表示的字母组合. 给出数字到字母的映射如下(与电话按键相同).注意 1 不对应任何字母. 示例: 输入:"23" 输出:[&quo ...
- Leetcode之回溯法专题-17. 电话号码的字母组合(Letter Combinations of a Phone Number)
[Leetcode]17. 电话号码的字母组合(Letter Combinations of a Phone Number) 题目描述: 给定一个仅包含数字 2-9 的字符串,返回所有它能表示的字母组 ...
- 【一天一道LeetCode】#17. Letter Combinations of a Phone Number
一天一道LeetCode (一)题目 Given a digit string, return all possible letter combinations that the number cou ...
- [LeetCode][Python]17: Letter Combinations of a Phone Number
# -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 17: Letter Combinations of a Phone Numb ...
- 《LeetBook》leetcode题解(17):Letter Combinations of a Phone Number[M]
我现在在做一个叫<leetbook>的免费开源书项目,力求提供最易懂的中文思路,目前把解题思路都同步更新到gitbook上了,需要的同学可以去看看 书的地址:https://hk029.g ...
- 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 ...
随机推荐
- Mysql笔记2-----重要小点
1.逻辑删除:
- python类的内置attr属性
class Foo: x=1 def __init__(self,y): self.y=y def __getattr__(self, item): print('----> from geta ...
- python面向对象三大特性之一封装
一.什么是封装 在程序设计中,封装(Encapsulation)是对具体对象的一种抽象,即将某些部分隐藏起来,在程序外部看不到,其 含义是其他程序无法调用. 要了解封装,离不开“私有化”,就是将类或者 ...
- python对大文件的处理
多线程框架中采取queue来实现线程间资源的互斥. 在文件过大的情况下,如果都读入内存的话,占用内存就太多了. 这里手动实现了一个多线程调用文件迭代器来使用f.next() # -*- coding: ...
- 【CodeForces 574B】Bear and Three Musketeers
[链接] 我是链接,点我呀:) [题意] [题解] 枚举每一条边(x,y) 然后再枚举y的出度z 看看g[x][z]是否等于1(表示联通) 如果等于1就说明找到了一个三元环,则尝试用它们的出度和-6更 ...
- 【codeforces 724E】Goods transportation
[题目链接]:http://codeforces.com/problemset/problem/724/E [题意] 有n个城市; 这个些城市每个城市有pi单位的物品; 然后已知每个城市能卖掉si单位 ...
- 2015 Multi-University Training Contest 9 hdu 5396 Expression
Expression Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total ...
- linux网络监控脚本
http://www.51testing.com/html/92/77492-828434.html
- 关于springboot整合的详细过程
Spring-boot http://tengj.top/2017/04/24/springboot0/
- Oracle里schema理解
在Oracle中,一个用户就是一个Schema,表都是建立在Schema中的,也可以理解为每个用户拥有不同的表.一个用户想访问另外一个用户,也就是另外一个schema的表的时候,可以用 usernam ...