题意:给一个电话号码,要求返回所有在手机上按键的组合,组合必须由键盘上号码的下方的字母组成。

思路:尼玛,一直RE,题意都不说0和1怎么办。DP解决。

 class Solution {
public:
vector<string> ans;
string str; void DFS(const string sett[], int siz, string t )
{
int n=str[siz]-'';
if(siz==str.size()){ans.push_back( t );return ;}
for(int i=; i<sett[n].size(); i++) DFS(sett, siz+, t+sett[n][i] );
} vector<string> letterCombinations(string digits) {
if(digits.empty()) return vector<string> ();
str=digits;
const string mapp[]={"","","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
DFS(mapp, , "");
return ans;
}
};

AC代码

LeetCode Letter Combinations of a Phone Number 电话号码组合的更多相关文章

  1. [LeetCode] Letter Combinations of a Phone Number 电话号码的字母组合

    Given a digit string, return all possible letter combinations that the number could represent. A map ...

  2. [LintCode] Letter Combinations of a Phone Number 电话号码的字母组合

    Given a digit string, return all possible letter combinations that the number could represent. A map ...

  3. LeetCode: Letter Combinations of a Phone Number 解题报告

    Letter Combinations of a Phone Number Given a digit string, return all possible letter combinations ...

  4. [LeetCode]Letter Combinations of a Phone Number题解

    Letter Combinations of a Phone Number: Given a digit string, return all possible letter combinations ...

  5. [LeetCode] 17. Letter Combinations of a Phone Number 电话号码的字母组合

    Given a string containing digits from 2-9inclusive, return all possible letter combinations that the ...

  6. 【LeetCode】17. Letter Combinations of a Phone Number 电话号码的字母组合

    作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 个人公众号:负雪明烛 本文关键词:电话号码, 字母组合,回溯法,题解,leetcode, ...

  7. [LeetCode]17. Letter Combinations of a Phone Number电话号码的字母组合

    Given a string containing digits from 2-9 inclusive, return all possible letter combinations that th ...

  8. LeetCode——Letter Combinations of a Phone Number

    Given a digit string, return all possible letter combinations that the number could represent. A map ...

  9. [LeetCode] Letter Combinations of a Phone Number

    Given a digit string, return all possible letter combinations that the number could represent. A map ...

随机推荐

  1. java.util.ConcurrentModificationException 解决办法(转)

    今天在项目的中有一个需求,需要在一个Set类型的集合中删除满足条件的对象,这时想当然地想到直接调用Set的remove(Object o)方法将指定的对象删除即可,测试代码:   public cla ...

  2. hdu 4888

    网络流建模,建模不难,难在找环: #include<cstdio> #include<algorithm> #include<vector> #include< ...

  3. 让32位Eclipse和64位Eclipse同时在64的Windows7上运行

    转自让32位Eclipse和64位Eclipse同时在64的Windows7上运行 参考这篇文章:http://wenku.baidu.com/view/57994c270066f5335a81214 ...

  4. javascript中li标签的排序和数组sort的用法

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...

  5. Python中Lambda, filter, reduce and map 的区别

    Lambda, filter, reduce and map Lambda Operator Some like it, others hate it and many are afraid of t ...

  6. Hibernate逍遥游记-第15章处理并发问题-003乐观锁

    1. 2. drop database if exists SAMPLEDB; create database SAMPLEDB; use SAMPLEDB; drop table if exists ...

  7. 获取其它进程窗口中的状态栏信息(FindWindowEx GetWindowThreadProcessId OpenProcess SendMessage轮番轰炸)

    HWND hWnd = ::FindWindow(NULL, _T("XXXXX")); if(NULL == hWnd) { return ; } HWND hWndStatus ...

  8. java:访问权限

    访问权限四大类:权限从大->小 1.public:   公共权限 2.protected:  受保护权限 3.default: 包级别访问权限/默认权限 4.private:   私有权限 以p ...

  9. 255. Verify Preorder Sequence in Binary Search Tree

    题目: Given an array of numbers, verify whether it is the correct preorder traversal sequence of a bin ...

  10. javascript精确计算

    一篇文章: 4 个用于执行高级数学计算的 JavaScript 库 numbers.js  Numeric Javascript accounting.js Tangle 有时只需要加减乘法能精确,没 ...