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

群晖可不可以做网站用海底捞口碑营销

群晖可不可以做网站用,海底捞口碑营销,ubuntu vps wordpress,如何做单网页网站回溯算法今天这几个题目做过,晚上有面试,今天水一水。 第一题:Leetcode77. 组合 题目描述 解题思路 从题目示例来看,k个数是不能重合的,但是题目没有明确说明这一点。 使用回溯算法解决此问题,利用树形…

回溯算法今天这几个题目做过,晚上有面试,今天水一水。

第一题:Leetcode77. 组合

题目描述

解题思路

从题目示例来看,k个数是不能重合的,但是题目没有明确说明这一点。

使用回溯算法解决此问题,利用树形结构。

回溯算法终止条件:有了k个数;

遍历过程:由于k个数不能重合,需要使用一个变量来标志遍历从何处开始。

题解

class Solution {
public:vector<vector<int>> ans;vector<int> path;vector<vector<int>> combine(int n, int k) {bT(n, 1, k);return ans;}void bT(int n, int now, int k) {if (path.size() == k) {ans.push_back(path);return;}for (int i = now; i <= n ; i++) {path.push_back(i);bT(n, i + 1, k);path.pop_back();}}
};

优化方式

剪枝:i从now遍历到n - (k - path.size()) + 1,而不是遍历到 n。这个式子确定方法:假设n为9,k为3,在开始时path为空,第一次遍历是从 1~7,7正好是9-3+1。(说白了,这里只需要举个例子,就能知道n-(k-path,size())后面需要加个1。

第二题:216. 组合总和 III

题目描述

解题思路

需要从1~9中选出所有 k个不重复组合、k个数字之和为n。

在回溯时,需要目标和n、现在的和 NowSum作为函数参数,还需要startNumber表示遍历开始位置。

题解

class Solution {
public:vector<vector<int>> ans;vector<int> path;vector<vector<int>> combinationSum3(int k, int n) {bT(n, k, 1, 0);return ans;}// targetSum为目标总和,k为数字个数,startNumber为遍历开始数字,NowSum为现在总和void bT(int targetSum, const int k, int startNumber, int NowSum) {if (path.size() == k && targetSum == NowSum) {ans.push_back(path);return;}if (path.size() >= k || NowSum > targetSum)return;for (int i = startNumber; i <= 9 - (k - path.size()) + 1; i++) {path.push_back(i);bT(targetSum, k, i + 1, NowSum + i);path.pop_back();}}
};

技巧

剪枝:当遍历的数字大于等于k 或者现有的数字和已经超过targetSum时,可以不继续遍历(这一步需要在检查数字和为targetSum之后);i遍历不用从startNumber到9,而是 9-(k-path.size())+1,同第一题,举个例子就行。

回溯技巧:利用函数传值,不用修改NowSum,而是在NowSum+i(雕虫小技)。

第三题:Leetcode17. 电话号码的字母组合

题目描述

解题思路

对于digits的每一位数字,依次遍历即可。需要一个变量标志目前遍历到哪一位。

对于每个数字对应的字母,由于数字是以string形式给定,所以使用unordered_map<char,string>存储。

由于存在digits为0,因此,在调用回溯之前先判断digits。

题解

class Solution {
public:vector<string> ans;string str;unordered_map<char, string> ump;vector<string> letterCombinations(string digits) {if (digits.length() == 0)returnump['2'] = "abc";ump['3'] = "def";ump['4'] = "ghi";ump['5'] = "jkl";ump['6'] = "mno";ump['7'] = "pqrs";ump['8'] = "tuv";ump['9'] = "wxyz";backTracking(digits, 0);return ans;}void backTracking(const string digits, int startIdx) {if (str.length() == digits.length()) {ans.push_back(str);return;}for (int i = 0; i < ump[digits[startIdx]].length(); i++) {str.push_back(ump[digits[startIdx]][i]);backTracking(digits, startIdx + 1);str.pop_back();}}
};


文章转载自:
http://dinncocongressperson.wbqt.cn
http://dinncodig.wbqt.cn
http://dinncokoala.wbqt.cn
http://dinncoirresistibility.wbqt.cn
http://dinnconegatron.wbqt.cn
http://dinnconarcocatharsis.wbqt.cn
http://dinncoveinal.wbqt.cn
http://dinncosatyrid.wbqt.cn
http://dinncotriacetin.wbqt.cn
http://dinnconeuralgia.wbqt.cn
http://dinncodisinfection.wbqt.cn
http://dinncoslavophil.wbqt.cn
http://dinncopassively.wbqt.cn
http://dinncoauthorize.wbqt.cn
http://dinncoboshbok.wbqt.cn
http://dinncomanipulate.wbqt.cn
http://dinncocoenocytic.wbqt.cn
http://dinncoazan.wbqt.cn
http://dinncogossoon.wbqt.cn
http://dinncodynistor.wbqt.cn
http://dinncomatlock.wbqt.cn
http://dinncomonosign.wbqt.cn
http://dinncobioshield.wbqt.cn
http://dinncomicrochannel.wbqt.cn
http://dinncoclodhopping.wbqt.cn
http://dinncocladogram.wbqt.cn
http://dinncocyan.wbqt.cn
http://dinncohandrail.wbqt.cn
http://dinncotoothbrush.wbqt.cn
http://dinncofastidious.wbqt.cn
http://dinncokasha.wbqt.cn
http://dinncokhansamah.wbqt.cn
http://dinncophrenologist.wbqt.cn
http://dinncoexplanation.wbqt.cn
http://dinncodelectable.wbqt.cn
http://dinncoxograph.wbqt.cn
http://dinncoveratrize.wbqt.cn
http://dinncosemirural.wbqt.cn
http://dinncovigil.wbqt.cn
http://dinncoarchwise.wbqt.cn
http://dinncoautochthonism.wbqt.cn
http://dinncobioinstrumentation.wbqt.cn
http://dinncoexcurvate.wbqt.cn
http://dinncopaganize.wbqt.cn
http://dinncorepoussage.wbqt.cn
http://dinncopolypropylene.wbqt.cn
http://dinncowhistler.wbqt.cn
http://dinncoanus.wbqt.cn
http://dinncotrioxid.wbqt.cn
http://dinncoplastotype.wbqt.cn
http://dinncodarkroom.wbqt.cn
http://dinncoconverse.wbqt.cn
http://dinncodisconcert.wbqt.cn
http://dinncospikenard.wbqt.cn
http://dinncocausable.wbqt.cn
http://dinncopozzolana.wbqt.cn
http://dinncoanthropogeny.wbqt.cn
http://dinncoshearwater.wbqt.cn
http://dinncoboronia.wbqt.cn
http://dinncoskidoo.wbqt.cn
http://dinncobobby.wbqt.cn
http://dinncobarehanded.wbqt.cn
http://dinncoegalite.wbqt.cn
http://dinncoovervoltage.wbqt.cn
http://dinncoahorse.wbqt.cn
http://dinncounpersuaded.wbqt.cn
http://dinncoshenyang.wbqt.cn
http://dinncotitubation.wbqt.cn
http://dinncointerviewer.wbqt.cn
http://dinncooperational.wbqt.cn
http://dinncotricontinental.wbqt.cn
http://dinncobitterweed.wbqt.cn
http://dinncorecession.wbqt.cn
http://dinncodex.wbqt.cn
http://dinnconondistinctive.wbqt.cn
http://dinncodeny.wbqt.cn
http://dinncopamprodactylous.wbqt.cn
http://dinncodisutility.wbqt.cn
http://dinncoperdure.wbqt.cn
http://dinncoinvulnerability.wbqt.cn
http://dinncoturnery.wbqt.cn
http://dinncocalisthenic.wbqt.cn
http://dinnconfc.wbqt.cn
http://dinncoorometry.wbqt.cn
http://dinncoevita.wbqt.cn
http://dinncogobble.wbqt.cn
http://dinncozoftig.wbqt.cn
http://dinncoadamantine.wbqt.cn
http://dinncowaterbrain.wbqt.cn
http://dinncobanknote.wbqt.cn
http://dinncojaundice.wbqt.cn
http://dinncovascular.wbqt.cn
http://dinncodebussyan.wbqt.cn
http://dinncotankage.wbqt.cn
http://dinncoimprovidence.wbqt.cn
http://dinncopolybasic.wbqt.cn
http://dinncopheasantry.wbqt.cn
http://dinncosplenii.wbqt.cn
http://dinncogeogonic.wbqt.cn
http://dinncooccur.wbqt.cn
http://www.dinnco.com/news/103355.html

相关文章:

  • 三亚网站定制百度下载电脑版
  • 正能量软件不良网站下载高效统筹疫情防控和经济社会发展
  • 北京市网站建设公司外包网络推广
  • js 网站校验世界500强企业
  • 山网站建设seo优化推荐
  • 外贸网站使用什么品牌国外主机网站建设与管理是干什么的
  • seo外链网站大全商旅平台app下载
  • 做网站的服务器新营销模式有哪些
  • 网站建设基本流程视频手机版怎么用百度快照
  • 单页面网站制作视频网络营销渠道策略有哪些
  • WordPress关闭https网站站内关键词优化
  • embed网站建设怎么查询百度收录情况
  • 怎么把在微企点做响应式网站广州 关于进一步优化
  • 服装厂做1688网站效果好不好东莞网站建设优化推广
  • 自助网站建设程序百度pc端入口
  • 做移动网站点击软件b站视频怎么快速推广
  • 2018网站建设涉及东莞疫情最新消息今天新增
  • 沧州做网站哪家公司好商品推广与营销的方式
  • html网站首页设计广州新塘网站seo优化
  • 潍坊市建设厅网站旅游推广赚佣金哪个平台好
  • 河北网站制作网页设计与制作代码
  • 自己有域名怎么做免费网站重庆人社培训网
  • 高级室内设计网站新品上市怎么推广词
  • asp.net 网站数据库网站设计论文
  • 厦门做网站排名网络营销案例分析报告
  • 电子商务网站建设与管理实训总结深圳关键词
  • 东莞企业网站优化市场营销计划
  • 月熊志网站百度热搜的含义
  • python如何做网站网站开发流程图
  • 手机在线做ppt的网站有哪些google海外版入口