Leetcode_016 Letter Combinations of a Phone Number
来源:互联网 发布:嵌入式好还是java好 编辑:程序博客网 时间:2024/05/21 09:16
这一题比较简答,但是这么简单的题我都敲了30多分钟,结果还有问题,修改,最后花了1个小时。。。。只能感叹自己水平太渣了,不熟练
class Solution {public: vector<string> letterCombinations(string digits) { vector<string> svec{ " ","", "abc","def","ghi","jkl","mno","pqrs","tuv","wxyz" };vector<string> resultvec;for (int i = 0; i < digits.size(); ++i)combin(svec[digits[i] - '0'], resultvec);return resultvec; }private: void combin(string s, vector<string> &svec){if (svec.empty()){string temp;for (int i = 0; i < s.size(); ++i)svec.push_back(temp + s[i]);return;}vector<string> ss;for (int time = 0; time < s.size(); ++time){vector<string> temp;for (vector<string>::iterator ite = svec.begin(); ite != svec.end(); ++ite)temp.push_back(*ite + s[time]);ss.insert(ss.begin(), temp.begin(), temp.end());}svec = ss;}};
0 0
- Leetcode_016 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
- LeetCode18:Letter Combinations of a Phone Number
- Letter Combinations of a Phone Number
- 【leetcode】Letter Combinations of a Phone Number
- LeetCode: Letter Combinations of a Phone Number
- Letter Combinations of a Phone Number
- Letter Combinations of a Phone Number
- [LeetCode]Letter Combinations of a Phone Number
- LeetCode-Letter Combinations of a Phone Number
- Letter Combinations of a Phone Number
- [LeetCode] Letter Combinations of a Phone Number
- Letter Combinations of a Phone Number
- LeetCode - Letter Combinations of a Phone Number
- Java-位运算符
- 0007.Scala类的属性和对象私有字段实战详解
- strong和weak
- 1083 -- 分!分!分! 学生的命根
- 网站计数器
- Leetcode_016 Letter Combinations of a Phone Number
- Apache与Nginx的优缺点比较
- 25Reverse Nodes in k-Group
- 1084 -- 找子串
- 删除一个链表中的节点
- 安装go语言
- 0008.Scala主构造器、私有构造器、构造器重载实战详解
- 1085 -- 判断奇偶性
- 已知圆弧的一些信息,求得圆弧上中间点的坐标的方法(C++语言描述)