LeetCode: Letter Combinations of a Phone Number
来源:互联网 发布:常用国家域名 编辑:程序博客网 时间:2024/06/12 08:55
题目:
https://oj.leetcode.com/problems/letter-combinations-of-a-phone-number/
分析:
DFS
代码:
class Solution{public:vector<string> letterCombinations(string digits){string solution;dfs(digits, 0, solution);return res;}void dfs(string &digits, int index, string &solution){if (index == digits.size()){res.push_back(solution);return;}else{for (auto &r : key[digits[index] - '0']){solution.push_back(r);dfs(digits, index+1, solution);solution.pop_back();}}}vector<string> res;string key[10] = {"", "", "abc", "def", "ghi", "jkl", "mno","pqrs", "tuv", "wxyz"};};
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
- selenium2.0(WebDriver) API
- 网络赛之Dice (BFS,hdu5012)
- HDU 2149 Public Sale(巴什博弈论)
- static的作用
- java_web之ServletContext应用
- LeetCode: Letter Combinations of a Phone Number
- 实现物体的左右旋转
- java对于半角和全角的转换
- 牛腩新闻发布系统总结
- SAE邮件服务saemail
- socialExperience
- VMware或VirtualBox能ping通主机但不能上网解决
- leetcode-Same Tree
- shiny server安装 配置 管理