LeetCode Letter Combinations of a Phone Number 电话号码组合
题意:给一个电话号码,要求返回所有在手机上按键的组合,组合必须由键盘上号码的下方的字母组成。
思路:尼玛,一直RE,题意都不说0和1怎么办。DP解决。
class Solution {
public:
vector<string> ans;
string str;
void DFS(const string sett[], int siz, string t )
{
int n=str[siz]-'';
if(siz==str.size()){ans.push_back( t );return ;}
for(int i=; i<sett[n].size(); i++) DFS(sett, siz+, t+sett[n][i] );
}
vector<string> letterCombinations(string digits) {
if(digits.empty()) return vector<string> ();
str=digits;
const string mapp[]={"","","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
DFS(mapp, , "");
return ans;
}
};
AC代码
LeetCode Letter Combinations of a Phone Number 电话号码组合的更多相关文章
- [LeetCode] Letter Combinations of a Phone Number 电话号码的字母组合
Given a digit string, return all possible letter combinations that the number could represent. A map ...
- [LintCode] Letter Combinations of a Phone Number 电话号码的字母组合
Given a digit string, return all possible letter combinations that the number could represent. A map ...
- 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 ...
- [LeetCode] 17. Letter Combinations of a Phone Number 电话号码的字母组合
Given a string containing digits from 2-9inclusive, return all possible letter combinations that the ...
- 【LeetCode】17. Letter Combinations of a Phone Number 电话号码的字母组合
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 个人公众号:负雪明烛 本文关键词:电话号码, 字母组合,回溯法,题解,leetcode, ...
- [LeetCode]17. Letter Combinations of a Phone Number电话号码的字母组合
Given a string containing digits from 2-9 inclusive, return all possible letter combinations that th ...
- LeetCode——Letter Combinations of a Phone Number
Given a digit string, return all possible letter combinations that the number could represent. A map ...
- [LeetCode] Letter Combinations of a Phone Number
Given a digit string, return all possible letter combinations that the number could represent. A map ...
随机推荐
- IntelliJ IDEA 文件夹重命名--解决重命名后js文件引用找不到路径报404错误
情景: 说明:ExtJS是我后来的改的名字--原来叫extjs,可是当我把在页面的引用地址改为 src="ExtJS/.."后页面就报404错误,我把它改回之前的extjs就可以( ...
- WEB前端常用的测试工具
一.QUnit 前端测试工具 QUnit是一个强大的JavaScript单元测试框架,该框架是由jQuery团队的成员所开发,并且是jQuery的官方测试套件.Qunit是Jquery的单元测试框架, ...
- [CFgym]2015-2016 ACM-ICPC Pacific Northwest Regional Contest小结
*感谢两位浙江大佬带我飞 贴下成绩 div2 div1 *div2不是我打的上个厕所就5/11了 比赛小结 A [题目大意] 有n(n<=500)个机场,两两之间距离是g[i][j],每经停一个 ...
- [设计模式] 1/2 工程与抽象工程模式 factory & Abstrac Factory
转载 http://blog.csdn.net/wuzhekai1985 软件领域中的设计模式为开发人员提供了一种使用专家设计经验的有效途径.设计模式中运用了面向对象编程语言的重要特性:封装.继承.多 ...
- NET Framework 4 中的新 C# 功能
http://msdn.microsoft.com/zh-cn/magazine/ff796223.aspx C# 编程语言自 2002 年初次发布以来已经有了极大的改善,可以帮助程序员编写更清晰易懂 ...
- Bad configuration option localCommand
command-line: line 0: Bad configuration option: PermitLocalCommand 2011-12-08 14:04:54 标签:Bad confi ...
- moto xt800 刷机到2.2.2
老机器啊,原来2.1的系统大多数软件都不能装sbf刷机包+工具+教程下载地址:http://u.115.com/file/bhdlwl2x 刷完之后如果RSD Lite显示刷机结果为失败,不要担心,手 ...
- 函数执行到return就结束了
遇到return,函数就结束了,不会往下执行 测试: class User { String name; int age; boolean fun1(int i){ if(i==1){ return ...
- PowerDesigner的样式设置
原文:PowerDesigner的样式设置 PD提供了强大的配置功能,可以对生成的数据库对象命名.数据模型的展现进行设置.这里首先讲下样式的设置. 颜色和字体设置 1.单独设置某个对象的颜色和字体 1 ...
- C# 常用对象的的修饰符
class(类) 1.internal 表示类只能在当然程序集中访问,类默认修饰符 2.public 表示所有地方都可以访问,与internal是互斥的 3.abstract 抽象类,不能被实例化,只 ...