LeetCode Letter Combinations of a Phone Number 电话号码组合

时间:2023-01-10 10:37:42

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

思路:尼玛,一直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. &lbrack;LeetCode&rsqb; Letter Combinations of a Phone Number 电话号码的字母组合

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

  2. &lbrack;LintCode&rsqb; Letter Combinations of a Phone Number 电话号码的字母组合

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

  3. LeetCode&colon; Letter Combinations of a Phone Number 解题报告

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

  4. &lbrack;LeetCode&rsqb;Letter Combinations of a Phone Number题解

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

  5. &lbrack;LeetCode&rsqb; 17&period; Letter Combinations of a Phone Number 电话号码的字母组合

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

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

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

  7. &lbrack;LeetCode&rsqb;17&period; 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. &lbrack;LeetCode&rsqb; Letter Combinations of a Phone Number

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

随机推荐

  1. 手势-webview与scrollView重复手势处理

    // called when the recognition of one of gestureRecognizer or otherGestureRecognizer would be blocke ...

  2. 什么是EBC和EBO

    EBC英文全称为“Empty Base Class”,中文全称“空基类”.那什么是空基类呢?简单的说就是没有任何数据成员的类就称之为空基类.也就是EBC的类定义中不包含任何数据成员,那么这样一来可能大 ...

  3. Android核心分析之二十五Android GDI之共享缓冲区机制

    Androird GDI之共享缓冲区机制 1  native_handle_t对private_handle_t 的包裹     private_handle_t是gralloc.so使用的本地缓冲区 ...

  4. Oracle 基础 &lt&semi;2&gt&semi; --函数

    一:函数的定义 函数是用于返回特定数据的PL/SQL程序块 (函数必须返回一个值) 语法: create [or replace] function function_name--函数名称 [(par ...

  5. dp题目

    从别的地方看来,最近一直在啃DP,有个目标,更有动力了. 1.Robberies 连接 :http://acm.hdu.edu.cn/showproblem.php?pid=2955      背包; ...

  6. codeforces MemSQL start&lbrack;c&rsqb;up Round 2 - online version B 最长公共子系列

    题目链接:  http://codeforces.com/contest/335/problem/B 分析: 第一眼看上去串的长度为5*10^4, 冒似只能用O(n)的算法可解. 而这样的算法从来没见 ...

  7. &lbrack; An Ac a Day &Hat;&lowbar;&Hat; &rsqb; HihoCoder 1249 Xiongnu&&num;39&semi;s Land 线性扫描

    拿到了icpc北京站的参赛名额 感谢亮哥~ 虽然是地狱之战 但也要全力以赴! 题意: 有一片沙漠 n片绿洲 让你用一条线分成两部分 左≥右 而且分割线要尽量靠右 问线的位置 思路: 网上说可以二分 没 ...

  8. win8&period;1去掉鼠标右键回收站&OpenCurlyDoubleQuote;固定到开始”屏幕的方法

    平台:win8.1 问题:桌面“回收站”右键菜单里有个“固定到开始屏幕”,一不小心就误按,设法删除之. 打开注册表编辑器.在注册表编辑器里面定位到:HKEY_LOCAL_MACHINE\SOFTWAR ...

  9. Openstack &amp&semi; Ansible

    Opennstack Open source software for creating private and public clouds Manages the servers at these ...

  10. 【Android Developers Training】 107&period; 认知用户当前的行为

    注:本文翻译自Google官方的Android Developers Training文档,译者技术一般,由于喜爱安卓而产生了翻译的念头,纯属个人兴趣爱好. 原文链接:http://developer ...