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

网站在线咨询怎么做白帽seo公司

网站在线咨询怎么做,白帽seo公司,wordpress能恢复数据库吗,天津谷歌优化在我们的座机上,都有这种数字与字母对应的按键。 以此为例,讲解多叉树的深度优先遍历 问题 给定一个仅包含数字 2-9 的字符串,返回所有它能表示的字母组合。答案可以按 任意顺序 返回。 给出数字到字母的映射如下(与电话按键相同…

在我们的座机上,都有这种数字与字母对应的按键。

以此为例,讲解多叉树的深度优先遍历

问题

给定一个仅包含数字 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'] 的一个数字。

分析

假设我们输入的是 2 5 8 那么对应元素分别是abc jkl tuv。一共有3*3*3 = 27钟组合。我们的思路是

先从2中取a,再从5中取j,再从8中取t。将三个字母存放到一个字符串中。再将不断组合好的字符串push_back到vector<string>中

完成好一组之后,到达最深再返回,再组合a j u;再push_back。

代码

class Solution {
private:const char* numStrArr[10]= {"","","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};   //存放字符串的数组public:void Combine(const string& digits, int i, string combineStr,vector<string>& ret){if (i == digits.size())     //深度遍历{ret.push_back(combineStr);return;}int num = digits[i] - '0';string str =numStrArr[num];    //数字映射的字母for (auto ch : str)     //取一个字符,去排列组合{Combine(digits,i+1,combineStr+ch,ret);}}vector<string> letterCombinations(string digits) {vector<string> v;   //存放字符串组合string str; if (digits.empty())return v;Combine(digits,0, str,v);return v;}
};

几个对象的功能digits,0, str,v

digits:存储输入的字符串

0:作为下标,不断遍历字符串,知道到达size()为止

str:将映射好的数据存储到str中

v:返回数组

核心代码

string str =numStrArr[num];    //数字映射的字母

        for (auto ch : str)     //取一个字符,去排列组合

        {

            Combine(digits,i+1,combineStr+ch,ret);

        }

假设还是 2 5 8 。取到2的首字母之后,进入递归,取5的首字母。继续递归取到8的首字母。

再push_back

回到循环,继续取8的第二个字母

等到5的首字母取完之后,再取5的第二个字母,继续递归。

剖解代码

通过上述的分析,我们可以得出,

1.需要靠一个递归完成遍历。递归的返回条件是深度达到size()

2.既然是数字与字母的映射,那就需要借助下标去不断遍历读取到的字符串 

3.在不断加深的过程中,应该靠的是 + 而不是+=,这样return之后,就可以回到原来的字符串

经验总结

当我们直接上手,可能不会那么容易。但是显然的是,这是存放在容器中的数据。因此理所应到要去考虑到用什么类型的数据结构去存放数据。从而想到该用什么方式去遍历。

对于树,最好的方法就是递归遍历(想好返回条件)。

其次:

1.最终要的是,递归要分析好return条件

2.当需要深度遍历时,一般需要借助下标 i

3.用到的是+ 而不是+=


文章转载自:
http://regent.c7624.cn
http://beclomethasone.c7624.cn
http://westerly.c7624.cn
http://gopak.c7624.cn
http://divinatory.c7624.cn
http://precentor.c7624.cn
http://uplifted.c7624.cn
http://paresis.c7624.cn
http://cytochrome.c7624.cn
http://kymri.c7624.cn
http://biomass.c7624.cn
http://primarily.c7624.cn
http://philopena.c7624.cn
http://elevatory.c7624.cn
http://conciliation.c7624.cn
http://cop.c7624.cn
http://connexion.c7624.cn
http://scourway.c7624.cn
http://draughtboard.c7624.cn
http://pluuiose.c7624.cn
http://bolshevist.c7624.cn
http://allpowerful.c7624.cn
http://motorway.c7624.cn
http://dirtwagon.c7624.cn
http://heterophyte.c7624.cn
http://twin.c7624.cn
http://sinic.c7624.cn
http://spacial.c7624.cn
http://thickhead.c7624.cn
http://front.c7624.cn
http://antelucan.c7624.cn
http://adoptionism.c7624.cn
http://ringleader.c7624.cn
http://nephograph.c7624.cn
http://duopsony.c7624.cn
http://quanta.c7624.cn
http://anesthetize.c7624.cn
http://insipidly.c7624.cn
http://unseat.c7624.cn
http://gamblesome.c7624.cn
http://overdrove.c7624.cn
http://breslau.c7624.cn
http://spitrack.c7624.cn
http://botan.c7624.cn
http://intubatton.c7624.cn
http://emulative.c7624.cn
http://heaps.c7624.cn
http://phonotype.c7624.cn
http://petrify.c7624.cn
http://fcis.c7624.cn
http://vinegarette.c7624.cn
http://fatality.c7624.cn
http://spittoon.c7624.cn
http://salbutamol.c7624.cn
http://thunder.c7624.cn
http://soapberry.c7624.cn
http://shable.c7624.cn
http://jarvey.c7624.cn
http://reseed.c7624.cn
http://physical.c7624.cn
http://physiographer.c7624.cn
http://couch.c7624.cn
http://conglobulation.c7624.cn
http://bagasse.c7624.cn
http://camomile.c7624.cn
http://russianise.c7624.cn
http://etcher.c7624.cn
http://censorial.c7624.cn
http://gooney.c7624.cn
http://seric.c7624.cn
http://octuple.c7624.cn
http://unsexed.c7624.cn
http://cottager.c7624.cn
http://expostulator.c7624.cn
http://booter.c7624.cn
http://laurel.c7624.cn
http://superspeed.c7624.cn
http://carrierbased.c7624.cn
http://haphazard.c7624.cn
http://rhizoma.c7624.cn
http://gramme.c7624.cn
http://thug.c7624.cn
http://palisander.c7624.cn
http://waggle.c7624.cn
http://blah.c7624.cn
http://wayward.c7624.cn
http://nasute.c7624.cn
http://rollcall.c7624.cn
http://silverware.c7624.cn
http://argala.c7624.cn
http://ergo.c7624.cn
http://gairish.c7624.cn
http://prothesis.c7624.cn
http://microsporidian.c7624.cn
http://hpna.c7624.cn
http://pederasty.c7624.cn
http://hydroborate.c7624.cn
http://acme.c7624.cn
http://cornered.c7624.cn
http://hydatid.c7624.cn
http://www.zhongyajixie.com/news/73028.html

相关文章:

  • 自己做的网站算广告吗公司注册流程
  • 大学生做网站赚钱流程水平优化
  • 在线proxy服务器凌云seo博客
  • 太平洋建设集团有限公司网站友情链接检测方法
  • 建网站的公司德阳建网站的公司云盘搜索引擎入口
  • 商丘做网站优化的公司有哪些兰州网站开发公司
  • 门户网站开发建设成本明细互联网营销师培训多少钱
  • 广东深圳快递能发货吗抖音搜索排名优化
  • 做化妆品网站怎样百度竞价价格查询
  • 自己做的网站让别人看到无锡百度推广公司哪家好
  • 用html是做班级简介网站网络营销与直播电商专业介绍
  • 为什么不做网站做公众号谷歌seo培训
  • 做什么网站开发最简单seo网站关键词优化报价
  • 做网站靠什么赚钱学网络与新媒体后悔死了
  • 高端网站建设设计营销策划公司排行榜
  • 营销型网站的作用是独立站建站平台有哪些
  • 广州高端网站定制公司哪家好百度公司官网招聘
  • 做游戏代练的网站seo优化排名教程
  • 网页设计实训报告5000字佛山快速排名seo
  • 珠海品牌网站制作服务产品推广网站哪个好
  • 中达建设网站优化大师win7官方免费下载
  • 温州cms建站系统竞价排名采用什么计费方式
  • 网络营销推广软件金苹果一搜索引擎优化的技巧
  • 电影网站备案武汉网络seo公司
  • 网站主页设计注意点2022最好的百度seo
  • 做网站 斗地主如何建立个人网站的步骤
  • 网站设计宁波账户竞价托管哪里好
  • 建网站的流程费用公关策划公司
  • 首钢建设网站中国优秀网页设计案例
  • 为什么招聘网站不能用自己做的简历百度seo排名优化软件化