Leetcode 17. Letter Combinations of a Phone Number(水)
2024-09-05 21:37:37
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_;
}
};
最新文章
- MongoDB学习笔记—Linux下搭建MongoDB环境
- MyBatis入门(一)
- BZOJ 1191 【HNOI2006】 超级英雄Hero
- 使用Git时一些问题的处理
- Linux_rsyslogd日志服务(二)
- SQL Server 中字符串中包含字符串变量的表示方法
- I.MX6 SHT20 Linux 驱动移植
- infusion度量金字塔数据解释
- android错误 Android NAND: nand_dev_load_disk_state,
- 李洪强漫谈iOS开发[C语言-021]-运算符
- C# - winform使用Dictionary的时候,程序一闪而过!
- (转)asp.net动态设置标题title 关键字keywords 描述descrtptions
- C#生成高清缩略图
- 模板基础model
- 保持ssh连接长时间不断开的技巧
- 对vue.js的template编译的理解
- linux命令学习之:cp
- 运行msckf_vio
- logrotate 日志切割工具
- SpringBoot学习:使用spring-boot-devtools进行热部署
热门文章
- 【Qt开发】【VS开发】【Linux开发】OpenCV、Qt-MinGw、Qt-msvc、VS2010、VS2015、Ubuntu Linux、ARM Linux中几个特别容易混淆的内容
- kafka学习(四)
- 20191110 Spring Boot官方文档学习(4.1)
- MySQL插入emoji表情报错 SQLException: Incorrect string value 的两种解决方案
- python爬取b站排行榜
- [LeetCode] 137. 只出现一次的数字 II
- RocksDB Rate Limiter源码解析
- jQuery中$()可以有两个参数
- maven项目pom.xml报错: Failure to transfer org.apache.maven.plugins:maven-surefire-plugin:pom:2.7.1 from
- Linux架构之Nginx 常见问题