前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >【Leet Code】17. Letter Combinations of a Phone Number

【Leet Code】17. Letter Combinations of a Phone Number

作者头像
韩旭051
发布2019-11-08 00:42:02
4590
发布2019-11-08 00:42:02
举报
文章被收录于专栏:刷题笔记

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

本文链接:https://blog.csdn.net/shiliang97/article/details/101999438

Given a string containing digits from 2-9 inclusive, 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. Note that 1 does not map to any letters.

Example:

Input: "23" Output: ["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"]. Note:

Although the above answer is in lexicographical order, your answer could be in any order you want.

来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/letter-combinations-of-a-phone-number 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。

我现在好像都在搬运柳婼的代码~~~~

就当是兔式刷题吧。

先刷到一定程度,再用java龟式刷题好好学习

代码语言:javascript
复制
class Solution {
public:
    vector<string> letterCombinations(string digits) {
        vector<string> result;
        if(digits.length()==0){
            return result;
        }
        result.push_back("");
        vector<string> v ={"","","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
        
        for(int i=0;i<digits.length();i++){
            string s= v[digits[i]-'0'];
            vector<string> temp;
            for(int j=0; j<s.length();j++){
                for(int k=0;k<result.size();k++){
                    temp.push_back(result[k]+s[j]);
                }
            }
            result=temp;
        }
        return result;
    }
};

柳婼题解,又短又快,又好理解~~·

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019/10/03 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 我现在好像都在搬运柳婼的代码~~~~
  • 就当是兔式刷题吧。
  • 先刷到一定程度,再用java龟式刷题好好学习
  • 柳婼题解,又短又快,又好理解~~·
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档