Leetcode 17. Letter Combinations of a Phone Number(水)
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(水)的更多相关文章
- [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
1 题目: Given a digit string, return all possible letter combinations that the number could represent. ...
- Java [leetcode 17]Letter Combinations of a Phone Number
题目描述: Given a digit string, return all possible letter combinations that the number could represent. ...
- Leetcode 17.——Letter Combinations of a Phone Number
Given a digit string, return all possible letter combinations that the number could represent. A map ...
- [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] 17. Letter Combinations of a Phone Number ☆☆
Given a digit string, return all possible letter combinations that the number could represent. A map ...
- [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——17. Letter Combinations of a Phone Number
一.题目链接: https://leetcode.com/problems/letter-combinations-of-a-phone-number/ 二.题目大意: 给定一段数字字符串,其中每个数 ...
- LeetCode 17 Letter Combinations of a Phone Number (电话号码字符组合)
题目链接 https://leetcode.com/problems/letter-combinations-of-a-phone-number/?tab=Description HashMap< ...
随机推荐
- lsb-realse
[root@localhost ~]# lsb_release -a -bash: lsb_release: command not found 解决方法:yum install redhat-lsb ...
- 红帽学习笔记[RHCSA] 第三课[输出重定向、Vi编辑器]
第三课 关于Linux的输入输出 输入输出 0 stdin 标准输入 仅读取 1 stdout 标准输出 仅写入 2 stderr 标准错误 仅写入 3 filename 其他文件 读取和/或写入 输 ...
- 2019 计蒜之道 初赛 第一场 商汤的AI伴游小精灵
https://nanti.jisuanke.com/t/39260 根据题意我们可以知道 这是一个树 我们只需要找到出度最大的两个点就好了 如果包含根节点的话要-- 两个点相邻的话也要-- 数据很 ...
- java常用类详细介绍及总结:字符串相关类、日期时间API、比较器接口、System、Math、BigInteger与BigDecimal
一.字符串相关的类 1.String及常用方法 1.1 String的特性 String:字符串,使用一对""引起来表示. String声明为final的,不可被继承 String ...
- 卸载yum-mysql
注意事项:1. 卸载yum MYSQLsystemctl status mysqlsystemctl stop mysqlsystemctl disable mysqld rpm -qa | grep ...
- [零基础学python]啰嗦的除法
除法啰嗦的,不仅是python. 整数除以整数 看官请在启动idle之后.练习以下的运算: >>> 2/5 0 >>> 2.0/5 0.4 >>> ...
- link标签中rel属性的作用
Link标签有两个作用:1. 定义文档与外部资源的关系:2. 是链接样式表.link标签是用于当前文档引用外部文档的 这个标签的rel属性用于设置对象和链接目标间的关系,说白了就是指明你链进来的对象是 ...
- php-redis的配置与使用
从此处下载 https://codeload.github.com/phpredis/phpredis/zip/develop 也就php-redis的安装包,在zip格式,在windows下解压,将 ...
- jQuery进阶第三天(2019 10.12)
一.原生JS快捷的尺寸(属性)(注意这些属性的结果 不带PX单位) clientWidth/clientHeight =====> 获得元素content+padding的宽/高: offse ...
- Vue实现二级菜单的显示与隐藏
<html> <head> <title>Vue实现二级菜单的显示与隐藏</title> <script src="vue.js&quo ...