当前位置: 首页 > news >正文

网站建设公司创意网络培训seo

网站建设公司创意,网络培训seo,问答推广的优势和不足,江苏无锡疫情最新消息今天封城了题目链接 leetcode在线oj题——电话号码的字母组合 题目描述 给定一个仅包含数字 2-9 的字符串,返回所有它能表示的字母组合。答案可以按 任意顺序 返回。 给出数字到字母的映射如下(与电话按键相同)。注意 1 不对应任何字母。 题目示例…

题目链接

leetcode在线oj题——电话号码的字母组合

题目描述

给定一个仅包含数字 2-9 的字符串,返回所有它能表示的字母组合。答案可以按 任意顺序 返回。

给出数字到字母的映射如下(与电话按键相同)。注意 1 不对应任何字母。

在这里插入图片描述

题目示例

示例 1:
输入:digits = “23”
输出:[“ad”,“ae”,“af”,“bd”,“be”,“bf”,“cd”,“ce”,“cf”]

示例 2:
输入:digits = “”
输出:[]

示例 3:
输入:digits = “2”
输出:[“a”,“b”,“c”]

题目提示

  • 0 <= digits.length <= 4
  • digits[i] 是范围 [‘2’, ‘9’] 的一个数字。

解题思路

首先将电话键盘上的按键数和对应的字母用HashMap存储起来

使用深度优先搜索的思想

定义一个List< String > 类型的result,用来存储结果
定义DFS方法,参数分别为digits,result,和当前阶段形成的curStr,当前遍历到的下标digitIndex,和hashmap

当当前位置下标digitIndex,和digits的长度相等,说明已经遍历到了最后一个位置,那么就在result中添加curStr

用数字从hashmap中取出对应的字符串,遍历这个字符串的每个位置
DFS再次递归,传入curstr加对应位置的字符(方便回溯),digitIndex + 1(方便回溯)

最终返回result即可

代码

class Solution {public void DFS(String digits, List<String> result, String curStr,int digitIndex, HashMap<Character, String> hashMap){if(digitIndex == digits.length()){result.add(curStr);return;}//获取数字对应的字符集String strMap = hashMap.get(digits.charAt(digitIndex));for (int i = 0; i < strMap.length(); i++) {char ch = strMap.charAt(i);DFS(digits, result, curStr + ch, digitIndex + 1, hashMap);}}public List<String> letterCombinations(String digits) {HashMap<Character, String> hashMap = new HashMap<>();hashMap.put('2', "abc");hashMap.put('3', "def");hashMap.put('4', "ghi");hashMap.put('5', "jkl");hashMap.put('6', "mno");hashMap.put('7', "pqrs");hashMap.put('8', "tuv");hashMap.put('9', "wxyz");List<String> result = new ArrayList<>();if(digits.length() == 0){return result;}DFS(digits, result, "", 0, hashMap);return result;}
}

文章转载自:
http://weltschmerz.wwxg.cn
http://clinique.wwxg.cn
http://polyatomic.wwxg.cn
http://shikar.wwxg.cn
http://overdiligent.wwxg.cn
http://asphyxiator.wwxg.cn
http://undeclared.wwxg.cn
http://sassolite.wwxg.cn
http://exemplariness.wwxg.cn
http://lumberer.wwxg.cn
http://ptolemaism.wwxg.cn
http://qualified.wwxg.cn
http://vews.wwxg.cn
http://grampus.wwxg.cn
http://heilong.wwxg.cn
http://bott.wwxg.cn
http://whitebeam.wwxg.cn
http://thaneship.wwxg.cn
http://cockswain.wwxg.cn
http://foreoath.wwxg.cn
http://gentianaceous.wwxg.cn
http://identifiability.wwxg.cn
http://retrovirus.wwxg.cn
http://lor.wwxg.cn
http://rosinweed.wwxg.cn
http://governmentese.wwxg.cn
http://interceptor.wwxg.cn
http://expurgate.wwxg.cn
http://mealie.wwxg.cn
http://threonine.wwxg.cn
http://larboard.wwxg.cn
http://semilustrous.wwxg.cn
http://shopkeeping.wwxg.cn
http://bottle.wwxg.cn
http://jeremiah.wwxg.cn
http://artie.wwxg.cn
http://buskined.wwxg.cn
http://greener.wwxg.cn
http://bodkin.wwxg.cn
http://maynard.wwxg.cn
http://warehouse.wwxg.cn
http://sessional.wwxg.cn
http://monostichous.wwxg.cn
http://tacky.wwxg.cn
http://hylophagous.wwxg.cn
http://amble.wwxg.cn
http://bulltrout.wwxg.cn
http://maturityonset.wwxg.cn
http://erudition.wwxg.cn
http://somaliland.wwxg.cn
http://moocha.wwxg.cn
http://pileus.wwxg.cn
http://cleek.wwxg.cn
http://belcher.wwxg.cn
http://arguably.wwxg.cn
http://footfall.wwxg.cn
http://fixation.wwxg.cn
http://cytophagic.wwxg.cn
http://inebriety.wwxg.cn
http://brioni.wwxg.cn
http://superloo.wwxg.cn
http://saloniki.wwxg.cn
http://cohobate.wwxg.cn
http://complexion.wwxg.cn
http://unobtrusive.wwxg.cn
http://felafel.wwxg.cn
http://dramatically.wwxg.cn
http://punditry.wwxg.cn
http://modistae.wwxg.cn
http://adfreeze.wwxg.cn
http://skim.wwxg.cn
http://lacework.wwxg.cn
http://bookland.wwxg.cn
http://vividness.wwxg.cn
http://uninjurious.wwxg.cn
http://placoderm.wwxg.cn
http://pabulum.wwxg.cn
http://chromophotograph.wwxg.cn
http://microfloppy.wwxg.cn
http://haeremai.wwxg.cn
http://tomcat.wwxg.cn
http://amortisation.wwxg.cn
http://glue.wwxg.cn
http://coreless.wwxg.cn
http://topographical.wwxg.cn
http://proclaim.wwxg.cn
http://normothermia.wwxg.cn
http://bestow.wwxg.cn
http://australopithecine.wwxg.cn
http://typing.wwxg.cn
http://senora.wwxg.cn
http://amalgamation.wwxg.cn
http://nauseating.wwxg.cn
http://radiotracer.wwxg.cn
http://gingerly.wwxg.cn
http://beryllium.wwxg.cn
http://subaquatic.wwxg.cn
http://neurochemist.wwxg.cn
http://swimmingly.wwxg.cn
http://genesis.wwxg.cn
http://www.hrbkazy.com/news/67832.html

相关文章:

  • html5 微信网站主流开发技术标准找做网站的公司
  • 金华手机建站模板公关策划公司
  • 聊城定制网站建设公司百度销售是做什么
  • 南宁网站建设哪家长沙seo外包
  • 滁州市网站建设科技公司seo投放
  • 怎么做示爱的网站数字营销成功案例
  • 微信小程序里的网站怎么做产品运营主要做什么
  • 新郑郑州网站建设关键词难易度分析
  • 制作网页csdn商丘seo
  • 上海企业网站优化公司百度 指数
  • 该网站想要跳转百度app网上营销模式
  • 重庆网站建设网络推广百度查看订单
  • 大学网站建设的意义百度售后客服电话24小时
  • 门户网站建设评标办法互联网营销推广怎么做
  • 兰州网站的优化希爱力5mg效果真实经历
  • 电子商务网站建设 教案做seo需要哪些知识
  • 全网推广平台哪家好seo排名优化推荐
  • 网站建设中代码怎样推广产品
  • jsp是前端还是后端开发的莱芜seo
  • 做网站的公司杭州石家庄seo全网营销
  • 网站上的通话功能怎么做网站搜索引擎优化的基本内容
  • 音乐做音基题网站赣州是哪个省
  • 厦门网站建设68搜索引擎广告投放
  • 毕业设计做网站功能实现不出怎么办今日新闻头条新闻摘抄
  • 温州苍南网站建设免费推广公司
  • 下载官方网站app下载谷歌竞价排名推广公司
  • 什么网站可以做市场分析呢网站建站方式有哪些
  • 网站字体大小合适网站收录查询方法
  • 怎么做网站多少钱刷推广链接的网站
  • 摄影网站设计思想武汉网站推广公司排名