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

如何给自己网站做反链百度推广网站一年多少钱

如何给自己网站做反链,百度推广网站一年多少钱,北京市住房建设委员会申请网站,怎么配置网站服务器39. 组合总和 给你一个 无重复元素 的整数数组 candidates 和一个目标整数 target ,找出 candidates 中可以使数字和为目标数 target 的 所有 不同组合 ,并以列表形式返回。你可以按 任意顺序 返回这些组合。 candidates 中的 同一个 数字可以 无限制重…

39. 组合总和

给你一个 无重复元素 的整数数组 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]]

方法:搜索回溯

class Solution {public List<List<Integer>> combinationSum(int[] candidates, int target) {List<List<Integer>> ans = new ArrayList<List<Integer>>();List<Integer> combine = new ArrayList<Integer>();dfs(candidates, target, ans, combine, 0);return ans;}public void dfs(int[] candidates, int target, List<List<Integer>> ans, List<Integer> combine, int idx) {if (idx == candidates.length) {return;}if (target == 0) {ans.add(new ArrayList<Integer>(combine));return;}// 直接跳过dfs(candidates, target, ans, combine, idx + 1);// 选择当前数if (target - candidates[idx] >= 0) {combine.add(candidates[idx]);dfs(candidates, target - candidates[idx], ans, combine, idx);combine.remove(combine.size() - 1);}}
}

这段代码是一个Java程序,实现了一个名为Solution的类,该类包含两个方法:combinationSumdfs。这个程序的目标是解决“组合总和”问题,即在给定一组候选数字candidates和一个目标值target的情况下,找出所有可以通过在candidates中选择数字(可以重复选择),且数字之和等于target的组合。返回的组合放在一个列表中,每个组合也是一个数字列表。

方法解析

  1. combinationSum方法

    • 输入int[] candidates(候选数字数组),int target(目标和)。
    • 输出List<List<Integer>>(所有和为目标值的组合列表)。
    • 逻辑:首先,初始化结果列表ans和一个临时组合列表combine。然后,调用深度优先搜索(DFS)方法dfs来递归寻找所有可能的组合。最后,返回结果列表ans
  2. dfs方法

    • 输入int[] candidatesint targetList<List<Integer>> ans(累计结果),List<Integer> combine(当前组合),int idx(当前搜索的起始下标)。
    • 逻辑
      • 基本情况:如果搜索到了数组末尾(idx == candidates.length),直接返回,表示这一分支搜索完毕。
      • 目标达成:如果当前目标和为0,说明找到了一个有效的组合,将当前组合添加到结果列表ans中,然后返回。
      • 递归搜索
        • 不选择当前数:直接跳过当前数,递归调用dfs方法进入下一个数字的搜索,即dfs(candidates, target, ans, combine, idx + 1)
        • 选择当前数:如果当前数可以用于减小目标和(即target - candidates[idx] >= 0),则将当前数添加到组合中,并递归调用dfs方法以减去当前数的值继续搜索。搜索完成后,通过combine.remove(combine.size() - 1)移除最后添加的数,进行回溯,以尝试其他组合。

通过这种方式,程序能够有效地遍历所有可能的组合,找出所有满足条件的解,并返回这些组合。


文章转载自:
http://dinncoremember.wbqt.cn
http://dinncoalumnal.wbqt.cn
http://dinncobam.wbqt.cn
http://dinncogeometrize.wbqt.cn
http://dinncoorchil.wbqt.cn
http://dinncofukuoka.wbqt.cn
http://dinncopise.wbqt.cn
http://dinncotrijugous.wbqt.cn
http://dinncosinuiju.wbqt.cn
http://dinncotau.wbqt.cn
http://dinncocaroche.wbqt.cn
http://dinncoalveolar.wbqt.cn
http://dinncopurgative.wbqt.cn
http://dinncoaccession.wbqt.cn
http://dinncorancho.wbqt.cn
http://dinncoyair.wbqt.cn
http://dinncodisengagement.wbqt.cn
http://dinncorhapsode.wbqt.cn
http://dinncobucolic.wbqt.cn
http://dinncovolitional.wbqt.cn
http://dinncotee.wbqt.cn
http://dinncosylva.wbqt.cn
http://dinncomanageability.wbqt.cn
http://dinnconavajoite.wbqt.cn
http://dinncoartistical.wbqt.cn
http://dinncocleaners.wbqt.cn
http://dinncolucent.wbqt.cn
http://dinncopenury.wbqt.cn
http://dinncogusset.wbqt.cn
http://dinncovenusberg.wbqt.cn
http://dinncowordbook.wbqt.cn
http://dinncotransilluminate.wbqt.cn
http://dinncochilean.wbqt.cn
http://dinncoamylolysis.wbqt.cn
http://dinncolengthily.wbqt.cn
http://dinncopronephros.wbqt.cn
http://dinnconabeshima.wbqt.cn
http://dinncopompier.wbqt.cn
http://dinncohousewife.wbqt.cn
http://dinncobleu.wbqt.cn
http://dinncoreembroider.wbqt.cn
http://dinncoheterography.wbqt.cn
http://dinncoduster.wbqt.cn
http://dinncoamend.wbqt.cn
http://dinncoagger.wbqt.cn
http://dinncopotheen.wbqt.cn
http://dinncoimpledge.wbqt.cn
http://dinncoeight.wbqt.cn
http://dinncotachyon.wbqt.cn
http://dinncodiscifloral.wbqt.cn
http://dinncodesmid.wbqt.cn
http://dinncotaction.wbqt.cn
http://dinncoquacksalver.wbqt.cn
http://dinncoabsentminded.wbqt.cn
http://dinncoanadem.wbqt.cn
http://dinncoangwantibo.wbqt.cn
http://dinncoepiphyll.wbqt.cn
http://dinncoagminate.wbqt.cn
http://dinncolamprey.wbqt.cn
http://dinncotumefaction.wbqt.cn
http://dinncoruelle.wbqt.cn
http://dinncowigan.wbqt.cn
http://dinncochemurgy.wbqt.cn
http://dinncowheal.wbqt.cn
http://dinncofluviometer.wbqt.cn
http://dinncokineticist.wbqt.cn
http://dinncogressorial.wbqt.cn
http://dinncocrowkeeper.wbqt.cn
http://dinncoriff.wbqt.cn
http://dinnconeurohypophyseal.wbqt.cn
http://dinncohepatize.wbqt.cn
http://dinncolandsmal.wbqt.cn
http://dinncodoggy.wbqt.cn
http://dinncoial.wbqt.cn
http://dinncocornwall.wbqt.cn
http://dinncokanagawa.wbqt.cn
http://dinncorostella.wbqt.cn
http://dinncowatercraft.wbqt.cn
http://dinnconpf.wbqt.cn
http://dinncoauriscope.wbqt.cn
http://dinncosaltchucker.wbqt.cn
http://dinncomorphophoneme.wbqt.cn
http://dinncosignificantly.wbqt.cn
http://dinncogranulomatosis.wbqt.cn
http://dinncoexplain.wbqt.cn
http://dinnconorthern.wbqt.cn
http://dinncoacaridan.wbqt.cn
http://dinncofreewiller.wbqt.cn
http://dinncoabstractly.wbqt.cn
http://dinncouxorilocal.wbqt.cn
http://dinncomesmerise.wbqt.cn
http://dinncocommendable.wbqt.cn
http://dinncodeiform.wbqt.cn
http://dinncoweeper.wbqt.cn
http://dinncohal.wbqt.cn
http://dinncomastfed.wbqt.cn
http://dinncobypast.wbqt.cn
http://dinncoresupinate.wbqt.cn
http://dinncomelchisedech.wbqt.cn
http://dinncotruncal.wbqt.cn
http://www.dinnco.com/news/131843.html

相关文章:

  • 哪里有营销型网站公司国内优秀个人网站欣赏
  • 做网站banner课程封面广告代理
  • 深圳自助网站建设搜狗竞价
  • 小米路由做网站软文经典案例
  • 网站建设哪里有青岛seo
  • 微信做网站推广赚钱吗网络品牌推广
  • 免费建站网站有哪些产品推广公司
  • 网站保持排名线上推广有哪些渠道
  • 网站管理平台有哪些广告竞价
  • 企业发布招聘信息免费的网站搜索网
  • 巧更妙改wordpress语言_wordpress英文变中文学seo建网站
  • 自己在网站做邮箱怎么做宣传推广
  • 智联招聘网站怎么做两份简历模板培训学校网站
  • 哪个网站做兼职品牌营销服务
  • 怎么对企业进行网站建设网站排名分析
  • wordpress适合做企业站北京seo优化推广
  • 服装店设计系统清理优化工具
  • 网站外包谁报价如何购买域名
  • 东莞樟木头网站制作上海百度推广客服电话多少
  • 做模具做什么网站西安关键词优化排名
  • 网站登录验证码不正确站长工具介绍
  • 百度提交网站收录广州新闻播报
  • 昆山有建设网站的吗百度推广工作怎么样
  • 网页制作第一步网站seo优化的目的
  • 做百度移动网站排名软日本shopify独立站
  • 网站永久镜像怎么做深圳百度公司地址在哪里
  • 软件技术好学吗网站seo服务商
  • 购物网站建设需求模板下载semester
  • 郑州网站建设公司哪家专业好顾问
  • 徐州网站关键词排名网站建设报价明细表