LeetCode *** 17. Letter Combinations of a Phone Number
来源:互联网 发布:java在线答题系统源码 编辑:程序博客网 时间:2024/05/20 00:50
题目:
Given 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.
分析:
“你是一封信我是邮差,忙着去护送来不及拆开,里面完美的世界~”。。
代码:
class Solution {public: vector<string> letterCombinations(string digits) { if(digits.length()<1)return vector<string>(); string d[] = {"", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"}; vector<string> res({""}); for(int i=0;i<digits.size();++i){ vector<string> tmp; for(int j=0;j<d[digits[i]-'0'].length();++j) for(int k=0;k<res.size();++k) tmp.push_back(res[k]+d[digits[i]-'0'][j]); res=tmp; } return res; }};
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
- 剑指offer 包含min函数的栈
- CentOS6.7下LNMP环境安装zabbix3.0
- mvn常见命令
- linux驱动基础系列--linux rtc子系统
- 四级联动
- LeetCode *** 17. Letter Combinations of a Phone Number
- 金审系统与SAP接口
- 聊聊同步、异步、阻塞与非阻塞
- 抽象数据类型(ADT)
- Hadoop 架构
- 转载一篇很好的mysql锁分析的文章
- Hadoop简介
- nyoj 448 素数环
- 1014