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 ...
随机推荐
- 路飞学城Python-Day140
Django思维导图
- python数据分析------文本挖掘(jieba)
1.import jieba jieba的cut函数有三个模式:全模式.精准模式.搜索引擎模式 1 精确模式,试图将句子最精确地切开,适合文本分析: 2 全模式,把句子中所有的可以成词的词语都扫描出来 ...
- IOS - NSDate 自己挖的坑,自己跳
NSDate:5是坑啊啊! NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDat ...
- 关于linux系统的sendmail使用中的问题与解决
系统环境是ubuntu16.04 安装 sudo apt-get install sendmail 检查运行情况 sudo service sendmail status 结果如下,表示正在运行 ● ...
- XSS Chanllenges 6-10
Stage #6 测试代码</xss> 存在过滤,并且也没有其他输入点,尝试构建" onmousemove="alert(document.domain),并查看源代码 ...
- CentOS6.8安装
VMware下CentOS 6.8安装配置 简述 Linux的安装方法有很多种,下面,我们主要以镜像安装为例,介绍CentOS的安装过程及相关的参数设置,详细步骤如下. CentOS安装配置 ...
- PHP 使用 Kafka 安装拾遗
最近项目开发中需要使用 Kafka 消息队列.经过检索,PHP下面有通用的两种方式来调用 Kafka . php-rdkafka 扩展 以 PHP 扩展的形式进行使用是非常高效的.另外,该项目也提供了 ...
- Java 超类引用子类对象的示例代码
动态方法分配 dynamic method dispatch 一个被重写的方法的调用会在运行时解析,而不是编译时解析 Java 会根据在调用发生时引用的对象的类型来判断所要执行的方法 public c ...
- ORA-29857: 表空间中存在域索引和/或次级对象
今天小编在操作 oracle 数据库,删除表空间时引发了异常!! SQL> drop tablespace nbmap including contents; 为什么会造成以上的异常呢? 根据小 ...
- pl/sql输入括号后卡顿的解决方式
pl/sql输入括号后卡顿的解决方式 学习了:https://zhidao.baidu.com/question/298275368.html 工具->首选项->用户界面->代码助手 ...