17. Letter Combinations of a Phone Number
Medium

Given a string containing digits from 2-9 inclusive, 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. Note that 1 does not map to any letters.

Example:

Input: "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 {
public:
vector<string> letterCombinations(string digits) {
map<char,string> test;
test[''] = "abc";
test[''] = "def";
test[''] = "ghi";
test[''] = "jkl";
test[''] = "mno";
test[''] = "pqrs";
test[''] = "tuv";
test[''] = "wxyz";
vector<string> fa_;
vector<string> chil_;
fa_.push_back("");
for(int i = ; i < digits.length(); i++){
chil_.clear();
for(int j = ; j < fa_.size(); j++){
//printf("%d %s",test[digits[i]].length());
for(int k = ; k < test[digits[i]].length(); k++){
//printf("%s",test[digits[i]][k]);
chil_.push_back(fa_[j]+test[digits[i]][k]);
}
}
fa_ = chil_;
}
return chil_;
}
};

Leetcode 17. Letter Combinations of a Phone Number(水)的更多相关文章

  1. [LeetCode] 17. Letter Combinations of a Phone Number 电话号码的字母组合

    Given a string containing digits from 2-9inclusive, return all possible letter combinations that the ...

  2. [leetcode 17]Letter Combinations of a Phone Number

    1 题目: Given a digit string, return all possible letter combinations that the number could represent. ...

  3. Java [leetcode 17]Letter Combinations of a Phone Number

    题目描述: Given a digit string, return all possible letter combinations that the number could represent. ...

  4. Leetcode 17.——Letter Combinations of a Phone Number

    Given a digit string, return all possible letter combinations that the number could represent. A map ...

  5. [leetcode]17. Letter Combinations of a Phone Number手机键盘的字母组合

    Given a string containing digits from 2-9 inclusive, return all possible letter combinations that th ...

  6. [LeetCode] 17. Letter Combinations of a Phone Number ☆☆

    Given a digit string, return all possible letter combinations that the number could represent. A map ...

  7. [LeetCode]17. Letter Combinations of a Phone Number电话号码的字母组合

    Given a string containing digits from 2-9 inclusive, return all possible letter combinations that th ...

  8. LeetCode——17. Letter Combinations of a Phone Number

    一.题目链接: https://leetcode.com/problems/letter-combinations-of-a-phone-number/ 二.题目大意: 给定一段数字字符串,其中每个数 ...

  9. LeetCode 17 Letter Combinations of a Phone Number (电话号码字符组合)

    题目链接 https://leetcode.com/problems/letter-combinations-of-a-phone-number/?tab=Description HashMap< ...

随机推荐

  1. tensorflow学习之搭建最简单的神经网络

    这几天在B站看莫烦的视频,学习一波,给出视频地址:https://www.bilibili.com/video/av16001891/?p=22 先放出代码 #####搭建神经网络测试 def add ...

  2. 应用安全 - CMS - Discuz漏洞汇总

    SSV-90861 Date:2012 类型:敏感信息泄露 影响范围:DZ x2.5  POC:http://www.xx.xx/uc_server/control/admin/db.php http ...

  3. Sql注入校验

    /// <summary> /// Sql注入校验 /// </summary> /// <param name="listWord">字符&l ...

  4. vue仿阿里云后台管理(附加阿里巴巴图标使用)

    先看下页面截图,在线演示地址http://aliadmin.zengjielin.top 下面有开源的代码 页面分成三大部分头部,头部菜单栏,侧边菜单栏,右侧内容栏. 现在我们担心的是怎么使用侧边栏. ...

  5. python 并发编程 多进程 模拟抢票

    抢票是并发执行 多个进程可以访问同一个文件 多个进程共享同一文件,我们可以把文件当数据库,用多个进程模拟多个人执行抢票任务 db.txt {"count": 1} 并发运行,效率高 ...

  6. Java基础语法-运算符

    1算术运算符 1.1运算符和表达式 运算符:对常量和变量进行操作的符号. 表达式:用运算符把常量或者变量连接起来符合java语法的式子就可以称为表达式. 不同运算符链接的表达式体现的是不同类型的表达式 ...

  7. 一些重温CSS需要注意的小细节

    <!-- CSS是用于描述页面展示的语言 字体.颜色.大小.间距,将内容分为多列 或者简单的动画及其他的装饰效果 决定了长啥样 html房子的骨架 css负责装修 怎么装修一个房子呢? 首先就是 ...

  8. 获取客户机MAC地址 根据IP地址 获取机器的MAC地址 / 获取真实Ip地址

    [DllImport("Iphlpapi.dll")] private static extern int SendARP(Int32 dest, Int32 host, ref ...

  9. linux 进程1

    一. 进程的开始和结束 1.1. main函数的调用 a. 编译链接时的引导代码.操作系统下的应用程序其实在main执行前也需要先执行一段引导代码才能去执行main,我们写应用程序时不用考虑引导代码的 ...

  10. python字符串替换的2种方法

    python 字符串替换可以用2种方法实现:1是用字符串本身的方法.2用正则来替换字符串 下面用个例子来实验下:a = 'hello word'把a字符串里的word替换为python 1.用字符串本 ...