思路:用深搜遍历九宫格字符串,一开始做的时候发生了引用指向空地址的问题,后来发现是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. Deepin深度Linux系统安装记录

    测试设备:小米游戏本,最新版15.6进入安装后发现黑屏,所以使用15.5安装 Deepin 15.5 官方介绍页 官方下载 百度云下载 下载后得到文件夹15.5 Release 将里面的ISO镜像文件 ...

  2. activemq整合springboot使用(个人微信小程序用)

    1.引入依赖 <parent> <groupId>org.springframework.boot</groupId> <artifactId>spri ...

  3. 复习宝典之Maven项目管理

    查看更多宝典,请点击<金三银四,你的专属面试宝典> 第二章:Maven项目管理 Maven是基于项目对象模型(POM project object model),可以通过一小段描述信息(配 ...

  4. 免安装版MySQL8数据库的安装

    [环境准备] PC版本:Windows10企业版.64位操作系统 数据库:MySQL8.0.12-win64.zip免安装版 [彻底卸载已安装的MySQL数据库] 由于系统中MySQL数据库的卸载不彻 ...

  5. 7. CSS装饰网页的样式

    CSS中有哪些用来装饰网页的样式呢?在这里我们对一些常用的样式做了总结. 字体样式 /* * 一般样式书写 */ .font_style_1{ font-family: "华文行楷" ...

  6. Altium Designer常用快捷键

    一:Altium原理图快捷键:    Shift+左键选择    :实现多个目标选择    Ctrl+左键拖动    :保持连线拖动目标        Shift+c       :清除当前过滤(?? ...

  7. 查看Pyton的版本号和32/64位平台

    怎么查看Python的版本号?使用的Python是32位还是64位的?用以下两条Python 指令就可以知道. 方法1:通过Python代码查看 import platform import sys ...

  8. docker-compose入门示例:一键部署 Nginx+Tomcat+Mysql

    整体环境配置 整体环境的配置,如果一个一个 Dockerfile 去写,那么是相当麻烦的,好在 Docker 有一个名为 Docker-Compose 的工具提供,我们可以使用它一次性完成整体环境的配 ...

  9. app与php后台接口登录认证、验证(seesion和token)

    简要:随着电商的不断发展,APP也层次不穷,随着科技的发展主要登录形式(微信.QQ.账号/密码):为此向大家分享一下"app与php后台接口登录认证.验证"想法和做法:希望能够帮助 ...

  10. C数列下标 牛客OI赛制测试赛2

    链接:https://www.nowcoder.com/acm/contest/185/C来源:牛客网 给出一个数列 A,求出一个数列B. 其中Bi   表示 数列A中 Ai 右边第一个比 Ai 大的 ...