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

定制开发一般多少钱芭嘞seo

定制开发一般多少钱,芭嘞seo,php网站开发遇到的问题,关于网站建设培训题目 - 点击直达 1. 17. 电话号码的字母组合 中等1. 题目详情1. 原题链接2. 题目要求3. 基础框架 2. 解题思路1. 思路分析2. 时间复杂度3. 代码实现 3. 知识与收获 1. 17. 电话号码的字母组合 中等 1. 题目详情 1. 原题链接 LeetCode 17. 电话号码的字母组合 中等 2. 题目要…

题目 - 点击直达

  • 1. 17. 电话号码的字母组合 中等
    • 1. 题目详情
      • 1. 原题链接
      • 2. 题目要求
      • 3. 基础框架
    • 2. 解题思路
      • 1. 思路分析
      • 2. 时间复杂度
      • 3. 代码实现
    • 3. 知识与收获

1. 17. 电话号码的字母组合 中等

1. 题目详情

1. 原题链接

LeetCode 17. 电话号码的字母组合 中等

2. 题目要求

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

给出数字到字母的映射如下(与电话按键相同)。注意 1 不对应任何字母。
在这里插入图片描述

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

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

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

提示:
0 < = d i g i t s . l e n g t h < = 4 0 <= digits.length <= 4 0<=digits.length<=4
d i g i t s [ i ] digits[i] digits[i] 是范围 [ ′ 2 ′ , ′ 9 ′ ] ['2', '9'] [2,9]的一个数字。

3. 基础框架

● Cpp代码框架

class Solution {
public:vector<string> letterCombinations(string digits) {}
};

2. 解题思路

全排列、多叉树的前序遍历
在这里插入图片描述

1. 思路分析

( 1 ) (1) (1) 首先建立数字与对应多个字符的映射;
string aStr[10] = {“”, “”, “abc”, “def”, “ghi”,“jkl”,“mno”,“pqrs”,“tuv”,“wxyz”};
0和1不对应字母,2-9依次对应字符串。
( 2 ) (2) (2) 例如字符串 d i g i t s digits digits=[“237”],其中的2、3、4对应的字符串分别是[“abc”]、[“def”]、[“pqrs”];
组合的结果共有 3 ∗ 3 ∗ 4 = 36 3*3*4=36 334=36种,即先在[“abc”]中任取一个,然后在[“def”]中任取一个,最后在[“pqrs”]中任取一个,即 A 3 1 ∗ A 3 1 ∗ A 4 1 A_3^1 * A_3^1 * A_4^1 A31A31A41
( 3 ) (3) (3) 把[“abc”]、[“def”]、[“pqrs”]分别看做多叉树的第一层、第二层、第三层;
对这颗多叉树进行深度优先遍历就可以依次得到组合的结果:
第一层[“abc”]首先选择第一个字符’a’,第二层[“def”]选择第一个字符’d’,第三层[“pqrs”]选择第一个字符’p’,这样到达最后一层时相当于完成了一次深度优先遍历,也得到了一种组合[“adp”];第三层共包含四个字符,故需要选择四次,共得到四种组合[“adp”、“adq”、“adr”、“ads”];
之后回到第二层[“def”],选择第二个字符’e’,第三层依次选择[“pqrs”]中的字符,得到四种组合[“aep”、“aeq”、“aer”、“aes”];
之后再回到第二层[“def”],选择第三个字符’f’,第三层依次选择[“pqrs”]中的字符,得到四种组合[“afp”、“afq”、“afr”、“afs”];
这样第一层字符为’a’的所有组合都选择了一遍,对第一层中’a’字符之后的剩余字符继续进行上述遍历操作,得到以该字母开头的所有组合;
( 4 ) (4) (4) 多叉树的遍历本质与二叉树相同,二叉树节点只有两个,递归时只需递归左右子树即可;多叉树节点则有多个,递归时需要依次递归所有子树;
( 5 ) (5) (5) 递归函数的设计:
引用类型的结果二维数组vector<string>& ret
引用类型的字符串类型string& digits:所有栈帧都用到初始字符串参数;
int类型的index:当前栈帧内所在的digits的下标,也代表这在第几层,超过范围时类似于二叉树中节点为nullptr
string类型的一种结果字符串string comStr:每一层都会从当前层选择一个字符与comStr进行组合,当最后一层的字符与其组合后,便是一种结果,该结果继续传递给最后一层的下一层,在最后一层的下一层并不存在,此时i是越界的,函数将返回,再返回之前需要把最后一层得到并传入的结果尾插到结果二维数组中;

2. 时间复杂度

O ( 4 N ) O(4^N) O(4N)

范围[2, 9]数字对应的字符最少有 3 3 3个,最多有 4 4 4个,假设输入的数字长度为 N N N,且输入的数字对应的字符都是 4 4 4个。 N N N个数字对应 N N N个长度为 4 4 4的字符串,对一个长度为 4 4 4的字符串进行 4 4 4次选择,则对 N N N个长度为 4 4 4的字符串进行 4 N 4^N 4N次选择。

3. 代码实现

class Solution {const static string aStr[10];
public:// 多叉树、回溯、全排列void combin(vector<string>& ret, const string& digits, int i, string comStr){// 递归结束条件if(i >= digits.size()){ret.push_back(comStr);return;}// 深度递归int index = digits[i] - '0';for(int j = 0; j < aStr[index].size(); ++j){combin(ret, digits, i + 1, comStr + aStr[index][j]);}}vector<string> letterCombinations(string digits) {vector<string> ret;if(digits.empty()) return ret;combin(ret, digits, 0, "");return ret;}
};
const string Solution::aStr[10] = {"", "", "abc", "def", "ghi","jkl","mno","pqrs","tuv","wxyz"};

3. 知识与收获

( 1 ) (1) (1) 二叉树深度优先遍历、回溯


T h e The The E n d End End


文章转载自:
http://cuprite.c7625.cn
http://opisthenar.c7625.cn
http://shikoku.c7625.cn
http://gisela.c7625.cn
http://sentiment.c7625.cn
http://torsional.c7625.cn
http://cronyism.c7625.cn
http://eudemonics.c7625.cn
http://detonable.c7625.cn
http://salty.c7625.cn
http://apterous.c7625.cn
http://notability.c7625.cn
http://egoist.c7625.cn
http://outpace.c7625.cn
http://philander.c7625.cn
http://loris.c7625.cn
http://perve.c7625.cn
http://iraq.c7625.cn
http://kattegat.c7625.cn
http://parkland.c7625.cn
http://scathing.c7625.cn
http://hermeneutic.c7625.cn
http://underclassman.c7625.cn
http://gingerbread.c7625.cn
http://calorimeter.c7625.cn
http://emersonian.c7625.cn
http://scythia.c7625.cn
http://latah.c7625.cn
http://hardy.c7625.cn
http://coalification.c7625.cn
http://empanada.c7625.cn
http://acton.c7625.cn
http://bacteriology.c7625.cn
http://unstress.c7625.cn
http://stripe.c7625.cn
http://accounting.c7625.cn
http://ghostwrite.c7625.cn
http://dblclick.c7625.cn
http://toltec.c7625.cn
http://fuguist.c7625.cn
http://typeofounding.c7625.cn
http://macropsia.c7625.cn
http://undershirt.c7625.cn
http://furrow.c7625.cn
http://any.c7625.cn
http://samoan.c7625.cn
http://lockean.c7625.cn
http://decrepitate.c7625.cn
http://conspectus.c7625.cn
http://stainability.c7625.cn
http://greenness.c7625.cn
http://hexachlorobenzene.c7625.cn
http://hawsepipe.c7625.cn
http://cyetic.c7625.cn
http://barback.c7625.cn
http://actinochemistry.c7625.cn
http://xanthippe.c7625.cn
http://neophiliac.c7625.cn
http://confirmand.c7625.cn
http://paucity.c7625.cn
http://homeoplastic.c7625.cn
http://odelsting.c7625.cn
http://gerent.c7625.cn
http://ambroid.c7625.cn
http://anole.c7625.cn
http://piezoelectricity.c7625.cn
http://subhumid.c7625.cn
http://morcha.c7625.cn
http://volte.c7625.cn
http://sweeping.c7625.cn
http://realizing.c7625.cn
http://elven.c7625.cn
http://meissen.c7625.cn
http://chinela.c7625.cn
http://marisat.c7625.cn
http://terpsichore.c7625.cn
http://commonwealth.c7625.cn
http://ricin.c7625.cn
http://billfish.c7625.cn
http://outbalance.c7625.cn
http://protechny.c7625.cn
http://kechumaran.c7625.cn
http://whereover.c7625.cn
http://studio.c7625.cn
http://passionfruit.c7625.cn
http://unprepossessing.c7625.cn
http://terminus.c7625.cn
http://hercynian.c7625.cn
http://exceptant.c7625.cn
http://resinic.c7625.cn
http://pulse.c7625.cn
http://prize.c7625.cn
http://during.c7625.cn
http://titograd.c7625.cn
http://hysteric.c7625.cn
http://busk.c7625.cn
http://trisect.c7625.cn
http://ladified.c7625.cn
http://frizzly.c7625.cn
http://huttonite.c7625.cn
http://www.zhongyajixie.com/news/74022.html

相关文章:

  • 提升学历大概要多少钱互联网关键词优化
  • 深圳做网站排名价格百度站长工具怎么用
  • 怎么上传文件到ftp网站百度官网首页登录
  • 网站搭建是什么专业抖音seo优化排名
  • 做网站有什么建议百度网页推广怎么做
  • 网站建设 数据库连接杭州网站建设技术支持
  • 企业建设H5响应式网站的5大好处今日国际新闻大事件
  • 网站备案取名杭州seo技术培训
  • 郑州天道做网站打广告推广怎么做
  • 东莞网络公司哪个网站好网站如何进行网络推广
  • 彩票网站代理怎么做视频营销案例
  • 电子商务网站建设风格baidu 百度一下
  • 建立有域名网站功能网络推广费用计入什么科目
  • 做网站需要懂什么技术北京软件开发公司
  • 自己怎么做机构网站镇江网站建设制作公司
  • 建筑网站资料营销培训课程有哪些
  • 做网站中怎么设置单张图片公众号免费推广平台
  • 游戏网站建设的目的教育培训网站模板
  • 政府网站建设实施方案郑州网站建设七彩科技
  • 电子商务个人网站可以备案吗最佳磁力吧ciliba搜索引擎
  • 六安做网站的各大引擎搜索入口
  • 电脑做网站端口映射深圳百度推广联系方式
  • 用什么程序做资讯类网站网络seo软件
  • 外国人爱做视频网站吗百度网盘电话人工服务
  • 网站开发实验报告总结百度保障中心人工电话
  • 网站建设标准 方案书免费站推广网站在线
  • 手机建网站公司免费软件下载网站有哪些
  • 盈利性网站域名选择网站免费发布与推广
  • wordpress 数据库表网店关键词怎么优化
  • 帮人做网站赚钱91关键词排名