Letter Combinations of a Phone Number
Given a digit string, return all possible letter combinations that the number could represent.
A mapping of digit to letters (just like on the telephone buttons) is given below.
![]()
Input:Digit string "23"
Output: ["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"].
vector<string> letterCombinations(string digits) {
string trans[] = {"", " ", "abc", "def", "ghi", "jkl",
"mno", "pqrs", "tuv", "wxyz"};
vector<string> set;
string seq;
Generater(trans, digits, , seq, set);
return set;
}
void Generater(string trans[], string& digits,
int deep, string& result, vector<string>& set)
{
if(deep == digits.size())
{
set.push_back(result);
return;
}
int curDig = digits[deep] - ;
for(int i =; i < trans[curDig].size(); i++)
{
result.push_back(trans[curDig][i]);
Generater(trans, digits, deep+, result, set);
result.resize(result.size() -);
}
}
Letter Combinations of a Phone Number的更多相关文章
- [LintCode] Letter Combinations of a Phone Number 电话号码的字母组合
Given a digit string, return all possible letter combinations that the number could represent. A map ...
- 69. Letter Combinations of a Phone Number
Letter Combinations of a Phone Number Given a digit string, return all possible letter combinations ...
- 【leetcode】Letter Combinations of a Phone Number
Letter Combinations of a Phone Number Given a digit string, return all possible letter combinations ...
- [LeetCode][Python]17: Letter Combinations of a Phone Number
# -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 17: Letter Combinations of a Phone Numb ...
- Letter Combinations of a Phone Number:深度优先和广度优先两种解法
Letter Combinations of a Phone Number Given a digit string, return all possible letter combinations ...
- leetcode-algorithms-17 Letter Combinations of a Phone Number
leetcode-algorithms-17 Letter Combinations of a Phone Number Given a string containing digits from 2 ...
- 《LeetBook》leetcode题解(17):Letter Combinations of a Phone Number[M]
我现在在做一个叫<leetbook>的免费开源书项目,力求提供最易懂的中文思路,目前把解题思路都同步更新到gitbook上了,需要的同学可以去看看 书的地址:https://hk029.g ...
- Letter Combinations of a Phone Number - LeetCode
目录 题目链接 注意点 解法 小结 题目链接 Letter Combinations of a Phone Number - LeetCode 注意点 可以不用按字典序排序 解法 解法一:输入的数字逐 ...
- LeetCode: Letter Combinations of a Phone Number 解题报告
Letter Combinations of a Phone Number Given a digit string, return all possible letter combinations ...
- [LeetCode]Letter Combinations of a Phone Number题解
Letter Combinations of a Phone Number: Given a digit string, return all possible letter combinations ...
随机推荐
- word2vec使用说明
word2vec是一个将单词转换成向量形式的工具.可以把对文本内容的处理简化为向量空间中的向量运算,计算出向量空间上的相似度,来表示文本语义上的相似度. 一.理论概述 (主要来源于http://lic ...
- C/C++遍历Windows文件夹下的所有文件
因为文件夹中往往包含文件和文件夹.想要遍历所有的文件,必须遍历文件夹中所有的文件夹.很显然,这个描述满足递归的两个要素:(1)问题的规模在不断的缩小,且新问题的模式与旧问题相同.很显然文件夹中含有子文 ...
- tableView中的“点击加载更多”点击不到
假设当前的tableView是_tableView,则可以这样设置 _tableView.contentInset = UIEdgeInsetsMake(0, 0, 100, 0); 该属性用于设置当 ...
- JVM-对象
1.对象的创建 当虚拟机遇到一条new指令时,首先去检查这个指令的参数是否能在常量池中定位到一个类的符号引用,并且检查这个符号引用代表的类是否已经被加载.解析和初始化.如果没有,那必须先执行相应的类加 ...
- 项目管理软件---redmine安装配置
redmine是一个开源的项目管理软件,其主页是:http://www.redmine.org redmine是基于Ruby on Rails框架的,跨平台和跨数据库. 安装过程 ========== ...
- Jquery Table 操作
获取行号 var rowIndex = $("#TableId").find("tr").index($("#RowId")[0]); va ...
- Note_Master-Detail Application(iOS template)_05_ YJYMasterViewController.m
// YJYMasterViewController.m #import "YJYMasterViewController.h" #import "YJYDetailV ...
- S50非接触式IC卡性能简介(M1)
一.主要指标 分为16个扇区,每个扇区为4块,每块16个字节,以块为存取单位: 每个扇区有独立的一组密码及访问控制: 每张卡有唯一序列号,为32位: 具有防冲突机制,支持多卡操作: 无电源,自带天线, ...
- 新浪微博sdk bug
最近在做一个 iOS 的 cocos2d-x 项目接入新浪微博 SDK 的时候被“坑”了,最后终于顺利的解决了.发现网上也有不少人遇到一样的问题,但是能找到的数量有限的解决办法写得都不详细,很难让人理 ...
- 前端开发者应该知道的 CSS 小技巧
一些小技巧让你的CSS技术更专业 使用:not()去除导航上不需要的边框 为body添加行高 垂直居中任何元素 逗号分离的列表 使用负nth-child选择元素 使用SVG图标 文本显示优化 在纯CS ...