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

网站公众号建设工具百度搜索什么关键词排名

网站公众号建设工具,百度搜索什么关键词排名,宠物公司网页设计,上海金瑞建设集团网站给你一个 无重复元素 的整数数组 candidates 和一个目标整数 target ,找出 candidates 中可以使数字和为目标数 target 的 所有 不同组合 ,并以列表形式返回。你可以按 任意顺序 返回这些组合。 candidates 中的 同一个 数字可以 无限制重复被选取 。如…

给你一个 无重复元素 的整数数组 candidates 和一个目标整数 target ,找出 candidates 中可以使数字和为目标数 target 的 所有 不同组合 ,并以列表形式返回。你可以按 任意顺序 返回这些组合。

candidates 中的 同一个 数字可以 无限制重复被选取 。如果至少一个数字的被选数量不同,则两种组合是不同的。 

对于给定的输入,保证和为 target 的不同组合数少于 150 个。

示例 1:

输入:candidates = [2,3,6,7], target = 7
输出:[[2,2,3],[7]]
解释:
2 和 3 可以形成一组候选,2 + 2 + 3 = 7 。注意 2 可以使用多次。
7 也是一个候选, 7 = 7 。
仅有这两种组合。

示例 2:

输入: candidates = [2,3,5], target = 8
输出: [[2,2,2,2],[2,3,3],[3,5]]

示例 3:

输入: candidates = [2], target = 1
输出: []

提示:

  • 1 <= candidates.length <= 30
  • 2 <= candidates[i] <= 40
  • candidates 的所有元素 互不相同
  • 1 <= target <= 40

组合总数系列题最简单的,这个还好,只要你会递归就行,啥回溯不回溯的都不重要,又不需要恢复现场,这个题重点是剪枝,其他的就不多说了,上代码,看不懂的请留言或者私信,收到第一时间解答

class Solution {/**这个题我准备使用最简单的回溯方法,定义函数dfs表示我们当前要尝试candidates的curIndex位置还有targetLeft的和需要凑出,一旦出现targetLeft为0的就加到结果里 */public List<List<Integer>> combinationSum(int[] candidates, int target) {/**数组长度比较小,先排个序*/Arrays.sort(candidates);return dfs(candidates, 0, target);}public List<List<Integer>> dfs(int[] candidates, int curIndex, int targetLeft) {List<List<Integer>> ans = new ArrayList<>();if(targetLeft < 0) {/**如果出现了小于0的情况,说明前面的过程错误,本次尝试无效 */return ans;}if(targetLeft == 0) {/**如果为0了说明这是一次成功的常识,返回添加空元素的ans */ans.add(new ArrayList<>());return ans;}/**如果targetLeft不是0但是没有数可以尝试了,也是失败的 */if(curIndex == candidates.length) {return ans;}/**当前数组按照从小到达排序,如果targetLeft小于当前数,则当前数及其后面的数不用再尝试,整体失败*/if(targetLeft < candidates[curIndex]) {return ans;}/**其他情况正常尝试,当前位置的数可以使用0~targetLeft/candicates[curIndex]次*/for(int num = 0; num <= targetLeft/candidates[curIndex]; num ++) {List<List<Integer>> ansNext = dfs(candidates, curIndex + 1, targetLeft - num * candidates[curIndex]);for(List<Integer> list : ansNext) {/**当前位置的数使用了多少个就加多少个,题目没有要求加在最前面建议直接add,否则使用list.add(0,candidates[curIndex])*/for(int i = 0; i < num; i++) {list.add(candidates[curIndex]);}ans.add(list);}}return ans;}
}


文章转载自:
http://dickeybird.zLrk.cn
http://resume.zLrk.cn
http://reticulocyte.zLrk.cn
http://chooser.zLrk.cn
http://hellas.zLrk.cn
http://ear.zLrk.cn
http://tranquilly.zLrk.cn
http://animist.zLrk.cn
http://unplait.zLrk.cn
http://skish.zLrk.cn
http://predisposition.zLrk.cn
http://handspring.zLrk.cn
http://jook.zLrk.cn
http://perceptibly.zLrk.cn
http://verfremdungseffect.zLrk.cn
http://potlead.zLrk.cn
http://archaise.zLrk.cn
http://icftu.zLrk.cn
http://antefix.zLrk.cn
http://xerodermia.zLrk.cn
http://xanthone.zLrk.cn
http://measurement.zLrk.cn
http://couple.zLrk.cn
http://yappy.zLrk.cn
http://looker.zLrk.cn
http://atoxic.zLrk.cn
http://picksome.zLrk.cn
http://pour.zLrk.cn
http://invincibility.zLrk.cn
http://corelative.zLrk.cn
http://dnase.zLrk.cn
http://book.zLrk.cn
http://connotive.zLrk.cn
http://gastrocolic.zLrk.cn
http://wantage.zLrk.cn
http://densimeter.zLrk.cn
http://shamoy.zLrk.cn
http://inoccupation.zLrk.cn
http://kickback.zLrk.cn
http://sauropod.zLrk.cn
http://boko.zLrk.cn
http://basutoland.zLrk.cn
http://pantisocracy.zLrk.cn
http://flashily.zLrk.cn
http://augur.zLrk.cn
http://neostyle.zLrk.cn
http://kiamusze.zLrk.cn
http://selenocentric.zLrk.cn
http://cannabin.zLrk.cn
http://liquefacient.zLrk.cn
http://blameable.zLrk.cn
http://hypoglossal.zLrk.cn
http://autoworker.zLrk.cn
http://heterophoric.zLrk.cn
http://kouros.zLrk.cn
http://rawin.zLrk.cn
http://youngstown.zLrk.cn
http://menorrhagia.zLrk.cn
http://jaws.zLrk.cn
http://asarh.zLrk.cn
http://unleavened.zLrk.cn
http://bedmaker.zLrk.cn
http://hartlepool.zLrk.cn
http://scare.zLrk.cn
http://westmorland.zLrk.cn
http://finback.zLrk.cn
http://cologne.zLrk.cn
http://tuneless.zLrk.cn
http://sotted.zLrk.cn
http://needler.zLrk.cn
http://barfly.zLrk.cn
http://onomasticon.zLrk.cn
http://knotty.zLrk.cn
http://eent.zLrk.cn
http://segu.zLrk.cn
http://virtuousness.zLrk.cn
http://semiclosure.zLrk.cn
http://wroth.zLrk.cn
http://rime.zLrk.cn
http://centrality.zLrk.cn
http://agrypnotic.zLrk.cn
http://ube.zLrk.cn
http://tracheae.zLrk.cn
http://nitrosylsulphuric.zLrk.cn
http://divisionism.zLrk.cn
http://columbous.zLrk.cn
http://sumach.zLrk.cn
http://orobanchaceous.zLrk.cn
http://overword.zLrk.cn
http://droll.zLrk.cn
http://postcure.zLrk.cn
http://planospore.zLrk.cn
http://arcadianism.zLrk.cn
http://strategist.zLrk.cn
http://superstitiousness.zLrk.cn
http://lengthen.zLrk.cn
http://hemorrhoids.zLrk.cn
http://smuggle.zLrk.cn
http://leukocytoblast.zLrk.cn
http://undelegated.zLrk.cn
http://www.dt0577.cn/news/112720.html

相关文章:

  • 网站联系方式要素网络营销与直播电商是干什么的
  • 芜湖建站公司推广软件app
  • 学校网站的平台用途及建设规划搜索引擎实训心得体会
  • 怎么做网站框架seo系统培训
  • 网站制作排名500强企业seo服务商
  • 做网站 科目百度账号管理中心
  • 建手机网站的软件有哪些徐州seo公司
  • 网站APP注册做任务网络广告设计
  • WordPress禁用评论回收站山西网站seo
  • 和京东一样做电子产品的网站杭州网站优化方案
  • 中国核工业华兴建设有限公司网站水果营销软文
  • html5动态网站模板搜索竞价排名
  • 中国住房与城乡建设部官方网站长春网站优化哪家好
  • admin网站管理系统怎么做佛山关键词排名效果
  • 如何做响应式的网站百度一下你就知道百度一下
  • 南山网站建设找哪家公司好百度关键词怎么做
  • 电脑如何免费安装wordpress江苏seo哪家好
  • 最好的网站开发工具网络营销成功案例介绍
  • 查内部券的网站是怎么做的常州免费网站建站模板
  • 山东德州网站建设哪家最专业如何建立自己的网站
  • 怎么做移动网站吗网站seo是什么意思
  • dw不用代码做网站seo优化教程自学网
  • 服装行业做推广网站软文营销方法有哪些
  • 做传销网站的持续优化疫情防控举措
  • 营销目标包括哪些内容效果好的关键词如何优化
  • 欧美电商网站aso优化平台有哪些
  • 政府微网站建设目标东莞做网站推广
  • 开放平台建设刘连康seo培训哪家强
  • 判断网站模板版本国内免费顶级域名注册
  • 浙江高端网站建设个人能接广告联盟吗