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重复数据查询置为空
前两天产品有个需求,相同的商品因为价格不同而分开展示,但是明细还是算一条明细,具体区分展示出商品的价格和数量信息,其他重复的商品信息要置空. 需求并不难,用程序代码循环处理就可以了.但是后面涉及到打印 ...
- siblings() next() nextAll() nextUntil() prev() prevAll() prevUntil() 在 DOM 树中水平遍历
$(document).ready(function(){ $("h2").siblings(); });拿到h2标签的所有的同级元素什么标签都可以 $(document).rea ...
- Kattis - Game Rank
Game Rank Picture by Gonkasth on DeviantArt, cc by-nd The gaming company Sandstorm is developing an ...
- Flex元素布局规则总结,以及布局和容器
一.Flex中的元素分类从功能层面可以把Flex中的元素分为组件(Components)和容器(Containers)两大类:组件 - 是指那类具有明确交互或数据展示功能的元素,例如Button.Ch ...
- python与图灵机器人交互(WXPY版本)
开发者账号:wujunfeng , 开发者key:官网申请 #!/usr/bin/env python#-*- coding:utf-8 -*- @Author : wujf @Time:2018/ ...
- 2104 -- K-th Number
Description You are working for Macrohard company in data structures department. After failing your ...
- mysql进阶练习
一 . MySQL进阶练习 /*==========================创建班级表=============================*/ CREATE TABLE class ( ...
- javascript事件列表解说
javascript事件列表解说 事件 浏览器支持 解说 一般事件 onclick IE3.N2 鼠标点击时触发此事件 ondblclick IE4.N4 鼠标双击时触发此事件 onmousedown ...
- php设置cookie和删除cookie
设置cookie Example : - set - <?php setcookie( "name", "value", "future_tim ...
- android AndroidManifest.xml 属性详细解析
一.关于AndroidManifest.xml AndroidManifest.xml 是每个android程序中必须的文件.它位于整个项目的根目录,描述了package中暴露的组件(activiti ...