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"].

Note:
Although the above answer is in lexicographical order, your answer could be in any order you want.

class Solution {
private:
vector<string> res;
string temp;
public:
void getRes(string digits,int len,map<char,string> num_map,int index)
{
if(index>=len)
{
res.push_back(temp);
return;
}
char strNum=digits[index];
string strLetter=num_map[strNum];
for(int j=;j<strLetter.size();j++)
{
temp.push_back(strLetter[j]);
getRes(digits,len,num_map,index+);
temp.pop_back();
} }
vector<string> letterCombinations(string digits) {
map<char,string> num_map;
num_map['']="";
num_map['']="";
num_map['']="abc";
num_map['']="def";
num_map['']="ghi";
num_map['']="jkl";
num_map['']="mno";
num_map['']="pqrs";
num_map['']="tuv";
num_map['']="wxyz";
int len=digits.size();
if(len==)
return res;
getRes(digits,len,num_map,);
return res;
}
};

最新文章

  1. 转:RealThinClient LinkedObjects Demo解析
  2. elasticsearch分词插件的安装
  3. JS 日历控件
  4. Mysql数据库优化总结2
  5. [转载]线程间操作无效: 从不是创建控件“ListBox1”的线程访问它
  6. Visualsvn Server的搭建
  7. JavaScript Infinite scroll &amp; Masonry
  8. 小程序大智慧,sqlserver 注释提取工具
  9. window.location获取URL中各部分
  10. Redies安装,修配置,设置密码,
  11. c# 用户自定义转换
  12. mysql 计算两点经纬度之间的直线距离(具体sql语句)
  13. python学习路程1
  14. [转]golang的goroutine调度机制
  15. 算法竞赛入门经典-训练指南(10881-Piotr&#39;s Ants)
  16. 设计模式 笔记 责任链模式 chain of responsibility
  17. 给TextView加上多彩效果:改变部分字体的大小和颜色
  18. 问题排查之&#39;org.apache.rocketmq.spring.starter.core.RocketMQTemplate&#39; that could not be found.- Bean method &#39;rocketMQTemplate&#39; in &#39;RocketMQAutoConfiguration&#39; not loaded.
  19. vsftp服务器同步文件
  20. UIWindow的windowLevel详解

热门文章

  1. bzoj1052: [HAOI2007]覆盖问题(二分+构造)
  2. 开发系统级应用不被Kill
  3. X210串口配置与stdio移植
  4. PHP系统编程--01.多进程与多线程
  5. 安装在Linux下的jenkins执行windows下的bat命令
  6. 【BZOJ4373】算术天才⑨与等差数列 [线段树]
  7. 【51NOD-0】1089 最长回文子串 V2(Manacher算法)
  8. 程序员你为什么这么累? - Controller规范
  9. HTML5获取地理位置信息并在Google Maps上显示
  10. lnmp、lamp、lnmpa一键安装包(Updated: 2016-4-12)