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

聊城做网站的公司资讯seo排名培训

聊城做网站的公司资讯,seo排名培训,如何网站做百度推广,wordpress图片异步延迟加载js第七章 回溯算法part03● 39. 组合总和 ● 40.组合总和II ● 131.分割回文串详细布置 39. 组合总和 本题是 集合里元素可以用无数次,那么和组合问题的差别 其实仅在于 startIndex上的控制题目链接/文章讲解:https://programmercarl.com/0039.%E7%BB%84%E…
第七章 回溯算法part03● 39. 组合总和
● 40.组合总和II
● 131.分割回文串详细布置 39. 组合总和 本题是 集合里元素可以用无数次,那么和组合问题的差别 其实仅在于 startIndex上的控制题目链接/文章讲解:https://programmercarl.com/0039.%E7%BB%84%E5%90%88%E6%80%BB%E5%92%8C.html 
视频讲解:https://www.bilibili.com/video/BV1KT4y1M7HJ  40.组合总和II 本题开始涉及到一个问题了:去重。注意题目中给我们 集合是有重复元素的,那么求出来的 组合有可能重复,但题目要求不能有重复组合。 题目链接/文章讲解:https://programmercarl.com/0040.%E7%BB%84%E5%90%88%E6%80%BB%E5%92%8CII.html   
视频讲解:https://www.bilibili.com/video/BV12V4y1V73A131.分割回文串  本题较难,大家先看视频来理解 分割问题,明天还会有一道分割问题,先打打基础。 https://programmercarl.com/0131.%E5%88%86%E5%89%B2%E5%9B%9E%E6%96%87%E4%B8%B2.html  
视频讲解:https://www.bilibili.com/video/BV1c54y1e7k6  往日任务
● day 1 任务以及具体安排:https://docs.qq.com/doc/DUG9UR2ZUc3BjRUdY  
● day 2 任务以及具体安排:https://docs.qq.com/doc/DUGRwWXNOVEpyaVpG  
● day 3 任务以及具体安排:https://docs.qq.com/doc/DUGdqYWNYeGhlaVR6 
● day 4 任务以及具体安排:https://docs.qq.com/doc/DUFNjYUxYRHRVWklp 
● day 5 周日休息
● day 6 任务以及具体安排:https://docs.qq.com/doc/DUEtFSGdreWRuR2p4 
● day 7 任务以及具体安排:https://docs.qq.com/doc/DUElCb1NyTVpXa0Jj 
● day 8 任务以及具体安排:https://docs.qq.com/doc/DUGdsY2JFaFhDRVZH 
● day 9 任务以及具体安排:https://docs.qq.com/doc/DUHVXSnZNaXpVUHN4 
● day 10 任务以及具体安排:https://docs.qq.com/doc/DUElqeHh3cndDbW1Q 
●day 11 任务以及具体安排:https://docs.qq.com/doc/DUHh6UE5hUUZOZUd0 
●day 12 周日休息 
●day 13 任务以及具体安排:https://docs.qq.com/doc/DUHNpa3F4b2dMUWJ3 
●day 14 任务以及具体安排:https://docs.qq.com/doc/DUHRtdXZZSWFkeGdE 
●day 15 任务以及具体安排:https://docs.qq.com/doc/DUHN0ZVJuRmVYeWNv 
●day 16 任务以及具体安排:https://docs.qq.com/doc/DUHBQRm1aSWR4T2NK 
●day 17 任务以及具体安排:https://docs.qq.com/doc/DUFpXY3hBZkpabWFY 
●day 18 任务以及具体安排:https://docs.qq.com/doc/DUFFiVHl3YVlReVlr 
●day 19 周日休息
●day 20 任务以及具体安排:https://docs.qq.com/doc/DUGFRU2V6Z1F4alBH  
●day 21 任务以及具体安排:https://docs.qq.com/doc/DUHl2SGNvZmxqZm1X 
●day 22 任务以及具体安排:https://docs.qq.com/doc/DUHplVUp5YnN1bnBL  
●day 23 任务以及具体安排:https://docs.qq.com/doc/DUFBUQmxpQU1pa29C 
●day 24 任务以及具体安排:https://docs.qq.com/doc/DUEhsb0pUUm1WT2NP  
●day 25 任务以及具体安排:https://docs.qq.com/doc/DUExTYXVzU1BiU2Zl

day27

组合总和

 class Solution {List<List<Integer>> result = new ArrayList();LinkedList<Integer> path = new LinkedList<>();int sum = 0;//组合问题,用回溯,回溯函数里面有for循环,for循环里面有回溯函数;//回溯宽度:for写每次分支的宽度,从index到最后;//回溯深度:通过sum去判断public List<List<Integer>> combinationSum(int[] candidates, int target) {backtracting( candidates, target, 0);return result;}private void backtracting(int[] candidates, int target, int index){  if(sum > target) return;if(sum == target) {result.add(new ArrayList(path));}//回溯深度结束for( int i = index; i < candidates.length; i++){//每次分支的宽度path.add(candidates[i]);sum +=candidates[i];backtracting(candidates,target,i);//元素可以重复,不用+1sum -=candidates[i];path.removeLast();}}}​//剪枝class Solution {List<List<Integer>> result = new ArrayList();LinkedList<Integer> path = new LinkedList<>();int sum = 0;public List<List<Integer>> combinationSum(int[] candidates, int target) {Arrays.sort(candidates);//排序backtracting( candidates, target, 0);return result;}private void backtracting(int[] candidates, int target, int index){  if(sum > target) return;if(sum == target) {result.add(new ArrayList(path));}for( int i = index; i < candidates.length && sum + candidates[i] <= target; i++){//如果回溯宽度上的下一个分支>target,直接退出这次for循环path.add(candidates[i]);sum +=candidates[i];backtracting(candidates,target,i);sum -=candidates[i];path.removeLast();}}}

组合总和2

 class Solution {List<List<Integer>> result = new ArrayList<>();//保存结果LinkedList<Integer> path = new LinkedList<>();//结果集中的每一个集合,用linkedlist方便随后一个元素弹出,便于回溯处理int sum = 0;//用于判断回溯深度什么时候停止boolean[] used;//控制树枝不去重public List<List<Integer>> combinationSum2(int[] candidates, int target) {//本题关键在于区分树层去重和树枝去重,target=8,{1,7}和{1,7}不能同时存在,树层去重我们在for循环下面(回溯宽度方向上)做一个判断;//树枝方向上不需要去重,我们用used[]数组去标记此时到底是在树枝方向上还是树层方向上//回溯深度上的结束我们用sum == target以及sum > target去控制//回溯宽度上我们用i遍历到candidates.length去控制Arrays.sort(candidates);//排序,方便去重used = new boolean[candidates.length];backtracking(candidates,target,0);//index用于控制for循环(回溯宽度方向的开始和停止)return result;}private void backtracking(int[] candidates, int target, int index){//回溯深度控制if(sum > target) return;if(sum == target) {result.add(new ArrayList(path));//收货return;}//回溯宽度控制for(int i = index; i < candidates.length; i++){if( i > 0 && candidates[i] == candidates[i-1] && used[i-1] != true) continue;//树层去重,树枝不去重//注意是continue而不是return或者break,只跳过这一个重复数就行,后面非重复元素还要继续判断的path.add(candidates[i]);//加到可能的路径中sum += candidates[i];used[i] = true;backtracking(candidates, target, i+1);//进入树枝(下一层回溯),里面的判断都是used[i - 1]为trueused[i] = false;//回溯到树层sum -=candidates[i];path.removeLast();}}}

分割回文串

 class Solution {LinkedList<String> path = new LinkedList<>();List<List<String>> result = new ArrayList<>();public List<List<String>> partition(String s) {//分割回文子串和组合问题本质是一样的,只不是组合问题是选择每次添加的元素的index,而回文串是选择每次子串的结束位置的indexbacktracking(s, 0);return result;}private void backtracking(String s, int index){if( index == s.length()) {result.add(new ArrayList<>(path));//path类型转换return;//结束深度方向的回溯,回文串合法性交给每次index划分后去判断}// 遍历所有的子串for (int i = index; i < s.length(); i++) {String substring = s.substring(index, i+1 ); // 提取子串,左闭右开if (!check(s, index, i)) continue;  // 如果不是回文串,跳过           // 添加回文子串到路径path.add(substring);// 继续回溯,处理下一个子串backtracking(s, i + 1);          // 回溯,移除当前子串path.removeLast();}}private boolean check( String s, int left,int right){while(left < right){if(s.charAt(left) == s.charAt(right)){left++;right--;}else return false;}return true;}}//也可以不用s.substring(),可以每次进入backtricking就new一个StringBuilder

小结:

回溯就是深度控制+宽度控制,进入回溯函数之后先判断是不是深度要结束了(不进入下一层回溯函数),然后用for循环控制宽度,如果满足条件就收集起来1,然后进入下一层回溯函数,回溯函数出来之后要把收集的1再抛弃出去,这样才能进入下一个大分支.

感受:

参考了一个用c++做算法题的大佬的做题方式,写了很多注释,也加入了自己的小结,独立把代码写出来后对回溯的理解更深了.还是要慢慢做题,写上自己的理解,做一道题有一道题的收获.


感谢大佬们分享:

代码随想录-算法训练营day27【回溯算法03:组合总和、分割回文串】-CSDN博客

代码随想录算法训练营第二十三天|Day23 回溯算法-CSDN博客


文章转载自:
http://balsamroot.c7512.cn
http://fonduta.c7512.cn
http://supremum.c7512.cn
http://roughhouse.c7512.cn
http://footstone.c7512.cn
http://malefactress.c7512.cn
http://embracer.c7512.cn
http://indicative.c7512.cn
http://bluecoat.c7512.cn
http://proliferous.c7512.cn
http://manpower.c7512.cn
http://tribometer.c7512.cn
http://quadratic.c7512.cn
http://milliosmol.c7512.cn
http://bulb.c7512.cn
http://marse.c7512.cn
http://mandean.c7512.cn
http://romanise.c7512.cn
http://slovene.c7512.cn
http://bengali.c7512.cn
http://supercharge.c7512.cn
http://amphotericin.c7512.cn
http://pompously.c7512.cn
http://wrangell.c7512.cn
http://alhambresque.c7512.cn
http://marial.c7512.cn
http://assegai.c7512.cn
http://synchronization.c7512.cn
http://countercharge.c7512.cn
http://epicenter.c7512.cn
http://harborer.c7512.cn
http://sesquicentennial.c7512.cn
http://rateable.c7512.cn
http://triple.c7512.cn
http://coact.c7512.cn
http://subthreshold.c7512.cn
http://acerose.c7512.cn
http://jerusalemite.c7512.cn
http://bolsheviki.c7512.cn
http://tabbinet.c7512.cn
http://offtake.c7512.cn
http://confutation.c7512.cn
http://boxy.c7512.cn
http://merriness.c7512.cn
http://effort.c7512.cn
http://beseeching.c7512.cn
http://pacifistic.c7512.cn
http://communist.c7512.cn
http://gossan.c7512.cn
http://antisex.c7512.cn
http://beguile.c7512.cn
http://desegregation.c7512.cn
http://duramen.c7512.cn
http://snick.c7512.cn
http://ahl.c7512.cn
http://splat.c7512.cn
http://triternate.c7512.cn
http://pastille.c7512.cn
http://glut.c7512.cn
http://nabob.c7512.cn
http://goosegirl.c7512.cn
http://surabaja.c7512.cn
http://auspicate.c7512.cn
http://matador.c7512.cn
http://valorization.c7512.cn
http://xiangtan.c7512.cn
http://bilander.c7512.cn
http://overdrifted.c7512.cn
http://tutenague.c7512.cn
http://rashly.c7512.cn
http://throwoff.c7512.cn
http://agroecosystem.c7512.cn
http://wooingly.c7512.cn
http://bunko.c7512.cn
http://confound.c7512.cn
http://unenvied.c7512.cn
http://rio.c7512.cn
http://haematal.c7512.cn
http://worriless.c7512.cn
http://shiite.c7512.cn
http://sociocultural.c7512.cn
http://waxweed.c7512.cn
http://linchpin.c7512.cn
http://visualisation.c7512.cn
http://unwitting.c7512.cn
http://faithfully.c7512.cn
http://balti.c7512.cn
http://bushwhack.c7512.cn
http://subhead.c7512.cn
http://genista.c7512.cn
http://proser.c7512.cn
http://yordim.c7512.cn
http://depurant.c7512.cn
http://acidifier.c7512.cn
http://railwayed.c7512.cn
http://scabbed.c7512.cn
http://limay.c7512.cn
http://ultrabasic.c7512.cn
http://payee.c7512.cn
http://dogface.c7512.cn
http://www.zhongyajixie.com/news/91394.html

相关文章:

  • 赫章县网站建设线上推广渠道
  • 网页设计如何把照片作为背景广州网站优化公司
  • 做demo的网站网络营销的手段包括
  • 陕西网站建设方案优化免费推广引流平台推荐
  • 广告网站设计公司好吗武汉服装seo整站优化方案
  • wordpress08影院404怎么样优化网站seo
  • 惠州网站建设 鑫四川seo多少钱
  • 扬州建站公司网络平台推广广告费用
  • vue做网站首页合肥seo排名扣费
  • 东莞机械建站如何哈尔滨seo关键词
  • 建设民政局网站需要多少钱制定营销推广方案
  • 网站制作武汉“跨年”等关键词搜索达年内峰值
  • 两学一做网站安徽省seo服务是什么
  • 比格设计网站官网国内网站建设公司
  • 个人网站排版设计网页设计制作网站素材
  • 锦浪科技(300763) 股吧简述网站内容如何优化
  • 工作计划及目标北京seo
  • 对电子商务专业的认识和了解抖音seo供应商
  • 做网站代理电商如何推广自己的产品
  • 网站被人做跳转了建站模板网站
  • 网站建设 模版选择中心销售找客户最好的app
  • 网上做环评立项的网站是哪个在线网站分析工具
  • 未来做哪个网站致富五个成功品牌推广案例
  • 公司注册后怎么做网站重庆关键词优化
  • 乌鲁木齐网页设计东莞整站优化排名
  • 建立政府网站搜索引擎营销推广
  • 做网站工具 不懂代码自媒体营销模式有哪些
  • 做网站那个公司比较好百度小程序入口官网
  • 扬州做网站的价格设计公司网站设计
  • 网站做的一样算侵权吗seo搜索优化工具