思路:用深搜遍历九宫格字符串,一开始做的时候发生了引用指向空地址的问题,后来发现是vector不能直接=赋值。

class Solution {
public:
int len; string map[]={"abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
void search(int pos, string res, vector<string>& a, string digits){
if(pos == len) return;
string s = map[digits[pos] - ''];
for (int i = ;i < s.size(); i++)
{
if(pos == len - )a.push_back(res + s[i]);
else search(pos + , res + s[i], a, digits);
}
} vector<string> letterCombinations(string digits) {
vector<string> ans;
len = digits.size();
if(len == )return ans;
search(,"",ans,digits);
return ans;
}
};

leetcode个人题解——#17 Letter Combinations of a Phone Number的更多相关文章

  1. 《LeetBook》leetcode题解(17):Letter Combinations of a Phone Number[M]

    我现在在做一个叫<leetbook>的免费开源书项目,力求提供最易懂的中文思路,目前把解题思路都同步更新到gitbook上了,需要的同学可以去看看 书的地址:https://hk029.g ...

  2. [LeetCode][Python]17: Letter Combinations of a Phone Number

    # -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 17: Letter Combinations of a Phone Numb ...

  3. Leetcode 17. Letter Combinations of a Phone Number(水)

    17. Letter Combinations of a Phone Number Medium Given a string containing digits from 2-9 inclusive ...

  4. 刷题17. Letter Combinations of a Phone Number

    一.题目说明 题目17. Letter Combinations of a Phone Number,题目给了下面一个图,输入一个字符串包括2-9,输出所有可能的字符组合. 如输入23所有可能的输出: ...

  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

    1 题目: Given a digit string, return all possible letter combinations that the number could represent. ...

  8. 【一天一道LeetCode】#17. Letter Combinations of a Phone Number

    一天一道LeetCode (一)题目 Given a digit string, return all possible letter combinations that the number cou ...

  9. Java [leetcode 17]Letter Combinations of a Phone Number

    题目描述: Given a digit string, return all possible letter combinations that the number could represent. ...

随机推荐

  1. CoacoaPods安装使与使用超级详细教程

    对于一个iOS开发的初学者来说,并不知道第三方类库的存在,知道了也不知道如何使用,那么下面便来介绍一下使用方法. iOS开发常用的第三方类库是GitHub:https://github.com/ 在上 ...

  2. laravel 5.7 resources 本地化 简体中文

    使用方法: 新建目录[项目目录/resources/lang/zh] 按以下内容创建文件,并将内容复制到文件中 修改 config/app.php 'locale' => 'zh', 'fall ...

  3. 爬虫——Scrapy框架案例一:手机APP抓包

    以爬取斗鱼直播上的信息为例: URL地址:http://capi.douyucdn.cn/api/v1/getVerticalRoom?limit=20&offset=0 爬取字段:房间ID. ...

  4. PHPStorm等编辑器debug调试(包括使用postman、soapUI)

    很多人在开发的时候,需要进行断点调试,但是很多人配置了很多,还是调试不了,其实是不需要这么麻烦的. 注意:PHPStorm等编辑器debug的配置不用进行任何配置,默认配置就好 实质上,断点调试的时候 ...

  5. 5. CSS是什么

    CSS概念 CSS,层叠样式表,也叫做风格样式表.通过CSS我们可以为页面添加一个美丽的外观,获得更加良好的用户体验.不过值得我们注意的是和HTML一样,CSS也不是编程语言,它只是提供一种配置文件, ...

  6. 论反向ajax

    在讨论反向ajax之前,说一下我大二写的一个聊天程序,通过前端ajax不断向服务器发送请求(通过http连接),服务器进行一次数据库查询,然后返回结果,断开与服务器的链接(绝大部分都是无用的结果)来维 ...

  7. pyhton实现简单的木马程序

    十一的晚上,平时都在写工作的代码,好久没有专门看一些知识了,感觉想刚开始学c一样,搞到半夜 还是<python网络编程基础>,写了小脚本,没有任何结构,一句一句的往下写的,反正是可以实现想 ...

  8. 基于原生JS封装数组原型上的sort方法

    基于原生JS封装数组原型上的sort方法 最近学习了数组的原型上内置方法的封装,加强了用原生JS封装方法的能力,也进一步理解数组方法封装的过程,实现的功能.虽然没有深入底层,了解源码.以下解法都是基于 ...

  9. Android Studio 引入 Git 并提交代码

    File -> Settings -> Version Control -> Git -> Path to Git executable -> 选择本地 Git 可执行文 ...

  10. Android零碎知识点

    1.android:foreground="?attr/selectableItemBackground"   ###设置水波纹效果 2.android:contentDescri ...