leetcode-Letter Combinations of a Phone Number
来源:互联网 发布:社交行为数据挖掘 编辑:程序博客网 时间:2024/05/22 01:43
iven 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.
void Combination(vector<string> &ret, char *letter, string s){ if(*letter == 0) { ret.push_back(s); return; } vector<string> a = {" ","","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"}; int gap = *letter - '0'; int i = 0; while(a[gap][i] != 0) { Combination(ret, letter+1, s+a[gap][i]); i++; }}class Solution {public: vector<string> letterCombinations(string digits) { vector<string> ret; string s; Combination(ret,&digits[0],s); 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
- Mac OS使用技巧之十四:自定义文件图标
- 详解android:scaleType属性
- leetcode-Reverse Linked List II
- 地形简化算法,以后更新,先放个图
- 【BZOJ】【P1112】【POI2008】【砖块Klo】【题解】【map】
- leetcode-Letter Combinations of a Phone Number
- Android:lunchmode(Activity的四种启动模式介绍)
- 雇员系统
- ThreadPoolExecutor的分析与使用
- C++菜鸟成长之路(初级)近期总结
- BestCoder Round #11 (Div. 2)
- 【BestCoder】 HDOJ 5055 Bob and math problem
- Effective C++ 条款 49:了解new-handler的行为
- Cocos2d-X 愤怒的小鸟的实现------开始界面(二)