LeetCode 18. Letter Combinations of a Phone Number
来源:互联网 发布:mysql导入数据库 编辑:程序博客网 时间:2024/06/05 04:10
依题意做即可,输入为2-9间的数字。
代码:
class Solution {public: vector<string> letterCombinations(string digits) { vector<string> ret(1, ""); string letters[] = {"abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"}; for (size_t i = 0; i < digits.size(); ++ i) { string str = letters[digits[i]-'2']; for (int j = ret.size()-1; j >= 0; -- j) { for (int k = str.size()-1; k >= 0; -- k) { if (k != 0) { ret.push_back( ret[j] + str[k] ); } else { ret[j] += str[k]; } } } } return ret; }};
0 0
- LeetCode: Letter Combinations of a Phone Number
- LeetCode Letter Combinations of a Phone Number
- LeetCode: Letter Combinations of a Phone Number
- [Leetcode] Letter Combinations of a Phone Number
- [LeetCode] Letter Combinations of a Phone Number
- 【leetcode】Letter Combinations of a Phone Number
- LeetCode: Letter Combinations of a Phone Number
- [LeetCode]Letter Combinations of a Phone Number
- LeetCode-Letter Combinations of a Phone Number
- [LeetCode] Letter Combinations of a Phone Number
- LeetCode - Letter Combinations of a Phone Number
- LeetCode:Letter Combinations of a Phone Number
- LeetCode | Letter Combinations of a Phone Number
- leetcode Letter Combinations of a Phone Number
- Leetcode: Letter Combinations of a Phone Number
- 【leetcode】Letter Combinations of a Phone Number
- [LeetCode] Letter Combinations of a Phone Number
- leetcode: Letter Combinations of a Phone Number
- 《关于字符串的内存地址》纠错
- 窗口和控件闪烁解决方案
- MyEclipse10.7的 at com.genuitec.eclipse.ast.deploy.core.Deployment.<init>错误解决办法。
- 浏览器启动被hao123劫持
- VBA 增加工作表
- LeetCode 18. Letter Combinations of a Phone Number
- IT大牛告诉你一天内能学些什么
- CC1101 433无线模块,STM8串口透传
- 用python写makefile
- Java学习--面向对象的三大特征之一
- 快大三了,该确定专业方向了
- 活动图(Activity Diagram) - 项目分解篇
- 黑马程序员——OC学习总结14-16
- 让我们来嚼makefile: 自动推导功能