LeetCode_Letter Combinations of a Phone Number
- 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"].
水题: DFS
- int counts[] = {, , , , , , , , , };
- char letter[] = {'', '', 'a', 'd', 'g', 'j', 'm', 'p', 't', 'w'};
- class Solution {
- public:
- void DFS( string & digit,int i, string s)
- {
- if(i == size){
- result.push_back(s);
- return ;
- }
- int index = digit[i] - '' ;
- for(int j = ; j < counts[index] ; j++)
- {
- char c = letter[index]+j ;
- DFS(digit, i+, s+c);
- }
- }
- vector<string> letterCombinations(string digits) {
- // Start typing your C/C++ solution below
- // DO NOT write int main() function
- result.clear();
- size = digits.size();
- string s = "";
- DFS(digits, , s);
- return result ;
- }
- private :
- vector<string> result ;
- int size ;
- };
LeetCode_Letter Combinations of a Phone Number的更多相关文章
- [LintCode] Letter Combinations of a Phone Number 电话号码的字母组合
Given a digit string, return all possible letter combinations that the number could represent. A map ...
- 69. Letter Combinations of a Phone Number
Letter Combinations of a Phone Number Given a digit string, return all possible letter combinations ...
- 【leetcode】Letter Combinations of a Phone Number
Letter Combinations of a Phone Number Given a digit string, return all possible letter combinations ...
- [LeetCode][Python]17: Letter Combinations of a Phone Number
# -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 17: Letter Combinations of a Phone Numb ...
- Letter Combinations of a Phone Number:深度优先和广度优先两种解法
Letter Combinations of a Phone Number Given a digit string, return all possible letter combinations ...
- leetcode-algorithms-17 Letter Combinations of a Phone Number
leetcode-algorithms-17 Letter Combinations of a Phone Number Given a string containing digits from 2 ...
- 《LeetBook》leetcode题解(17):Letter Combinations of a Phone Number[M]
我现在在做一个叫<leetbook>的免费开源书项目,力求提供最易懂的中文思路,目前把解题思路都同步更新到gitbook上了,需要的同学可以去看看 书的地址:https://hk029.g ...
- Letter Combinations of a Phone Number - LeetCode
目录 题目链接 注意点 解法 小结 题目链接 Letter Combinations of a Phone Number - LeetCode 注意点 可以不用按字典序排序 解法 解法一:输入的数字逐 ...
- LeetCode: Letter Combinations of a Phone Number 解题报告
Letter Combinations of a Phone Number Given a digit string, return all possible letter combinations ...
随机推荐
- 在Fragment中使用BaiduMap SDK
1:fragment_bshdzh.xml <?xml version="1.0" encoding="utf-8"?> <LinearLay ...
- 【Xamarin破解补丁找不到?】
前面的博文,推荐竟然那么点数目?下面的这个网址是个各种破解资源的站点,里面说不定有你想要的. http://onhax.net/ 要学会在搜索框搜索... 好吧,其实里面就有Xamarin的破解补丁 ...
- 图解SSL/TLS协议(转)
本周,CloudFlare宣布,开始提供Keyless服务,即你把网站放到它们的CDN上,不用提供自己的私钥,也能使用SSL加密链接. 我看了CloudFlare的说明(这里和这里),突然意识到这是绝 ...
- Windows下AndroidStudio 中使用Git(AndroidStudio项目于GitHub关联)
前提条件 : 1. 安装 Git 客户端 下载链接 2. 有 GitHub 账号 (假设你已经有了一些git基础, 如果还一点都不会, 请去找其他加成学习) AndroidStudio项目发布到Git ...
- Calculate Number Of Islands And Lakes 解答
Question 1 1 1 1 1 01 0 1 0 0 11 0 1 0 0 11 1 0 1 1 1 1 is earth, 0 is water. i) count the number of ...
- Merge Sorted Array 解答
Question Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array ...
- POJ3261-哈希
这个题让求至少出现K次的最大长度的子串,属于最大化最小值问题,首先应该想到二分求字串的长度,二分的过程是O(logN)的,注意judge的时候怎样判断是否满足情况以及满足情况后l,r的变化.可以给每一 ...
- Linux Top 命令
TOP命令是Linux下常用的性能分析工具,能够实时显示系统中各个进程的资源占用状况. TOP是一个动态显示过程,即可以通过用户按键来不断刷新当前状态.如果在前台执行该命令,它将独占前台,直到用户终止 ...
- 神坑 关于&&的取值
a = 0&&"ssss": 结果a=0 a=true&&"w": 结果a=w: 类似于 前面是真的 会执行后面并返回后面 前面 ...
- ecshop 管理员不需要旧密码