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

别人做的网站怎么打开挖掘关键词的工具

别人做的网站怎么打开,挖掘关键词的工具,委托做的网站版权归属哪方,做网站搞笑口号Java Arrays.sort(数组) //排序 不讲究顺序的解答,都可以考虑一下排序是否可行。 39. 组合总和 错误解答 在写的时候需要注意,sum - candidates[i];很重要,也是回溯的一部分。 解答重复了。是因为回溯的for循环理解错了。 class Solutio…

Java

Arrays.sort(数组) //排序
不讲究顺序的解答,都可以考虑一下排序是否可行。

39. 组合总和

错误解答

在写的时候需要注意,sum -= candidates[i];很重要,也是回溯的一部分。
解答重复了。是因为回溯的for循环理解错了。

class Solution {List<List<Integer>> res = new ArrayList<List<Integer>>();public List<List<Integer>> combinationSum(int[] candidates, int target) {backtracking(candidates, target, 0, 0);return res;}List<Integer> path = new ArrayList<>();public void backtracking(int[] candidates, int target, int sum, int index) {if(sum > target) {return;}if(sum == target) {res.add(new ArrayList<>(path));return;}for(int i=0; i<candidates.length; i++) {sum += candidates[i];path.add(candidates[i]);backtracking(candidates,target,sum,i);sum -= candidates[i];path.remove(path.size()-1);}}
}

在这里插入图片描述

正确

  • 修改成下面这样就对了
    在这里插入图片描述

优化

不讲究顺序的解答,都可以考虑一下排序是否可行。
剪枝要先排序。

class Solution {List<List<Integer>> res = new ArrayList<List<Integer>>();public List<List<Integer>> combinationSum(int[] candidates, int target) {Arrays.sort(candidates);backtracking(candidates, target, 0, 0);return res;}List<Integer> path = new ArrayList<>();public void backtracking(int[] candidates, int target, int sum, int index) {if(sum == target) {res.add(new ArrayList<>(path));return;}for(int i=index; i<candidates.length; i++) {sum += candidates[i];if (sum > target) break;path.add(candidates[i]);backtracking(candidates,target,sum,i);sum -= candidates[i];path.remove(path.size()-1);}}
}

40.组合总和II

想得太简单了……

class Solution {List<List<Integer>> res = new ArrayList<List<Integer>>();public List<List<Integer>> combinationSum2(int[] candidates, int target) {Arrays.sort(candidates);back(candidates,target,0,0);return res;}List<Integer> path = new ArrayList<>();void back(int[] candidates, int target, int sum, int index) {if(sum > target) return;if(sum == target) {res.add(new ArrayList(path));}for(int i=index; i<candidates.length; i++) {path.add(candidates[i]);sum+=candidates[i];back(candidates,target,sum,index+1);sum-=candidates[i];path.remove(path.size()-1);   }}
}

131.分割回文串

http://www.bjxfkj.com.cn/article/870.html

相关文章:

  • 新网站怎样做外链网络推广的方法有
  • 重庆政府app下载本溪seo优化
  • 网站开发参考文献2015年后网站服务器怎么搭建
  • 融资网站建设哪些平台可以发广告
  • vs怎么做网站的首页百度提问在线回答问题
  • wordpress更改背景短视频seo询盘获客系统软件
  • 网络营销推广代理网站优化推广公司排名
  • wordpress视频网站用什么播放器搜索引擎优化策略应该包括
  • 求可以做问卷测试的网站企业网站seo
  • 宛城区网站建设奇零seo赚钱培训
  • wordpress淘宝api接口插件湛江seo推广公司
  • 电影网站制作教程湖南搜索引擎推广平台
  • 坪山模板网站建设公司排名前十的大学
  • 电商设计师常用的网站百度客户端电脑版下载
  • 编写网站用什么语言文章推广平台
  • wordpress企业站主题下载营销的三个基本概念是什么
  • 开封市网站开发公司南宁seo团队哪家好
  • 建设网站专业公司哪家好网站网页的优化方法
  • 在线做热图的网站营销型网站建设公司价格
  • 信息技术制作网站沈阳网站建设
  • 广州网站设计培训网络游戏推广员
  • 北京网站seo策划百度seo优化软件
  • wordpress的发件邮箱是多少广东公司搜索seo哪家强
  • 目前基金会网站做的比较好的谷歌搜索引擎网页版入口
  • 电商推广平台哪个好seo搜索引擎优化简历
  • 那种网站后台最好深圳全网营销平台排名
  • java php做网站百度图片识别搜索引擎
  • 浏阳疫情发布纵横seo
  • 网站过度优化首页被k广东疫情防控措施
  • 河北省建设厅网站登陆设置环球军事新闻最新消息