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

win网站建设seo 推广服务

win网站建设,seo 推广服务,网站建设与推广实训心得,智能网站建设哪家好39.组合总和 思路: 1.确定回溯函数参数:定义全局遍历存放res集合和单个path,还需要 candidates数组 targetSum(int)目标和。 startIndex(int)为下一层for循环搜索的起始位置。 2.终止条件…

39.组合总和

思路:

1.确定回溯函数参数:定义全局遍历存放res集合和单个path,还需要

  • candidates数组

  • targetSum(int)目标和。

  • startIndex(int)为下一层for循环搜索的起始位置。

2.终止条件:

  • 当不可能再出现解(sum(path)> target),return
  • 当遍历到决策树的叶子节点时(sum(path)==target)时,将当前结果的数组 path 放入答案数组 res中,递归停止。

3.遍历过程:数组可以重复,startindex从i开始

  • 从当前正在考虑元素,到数组结束为止,枚举出所有可选的元素。对于每一个可选元素:
    • 选择元素:将其添加到当前数组 path 中。
    • 递归搜索:在选择该元素的情况下,继续递归选择剩下元素。
    • 撤销选择:将该元素从当前结果数组 path 中移除。
class Solution:def combinationSum(self, candidates: List[int], target: int) -> List[List[int]]:res = []path = []def backtrack(candidates,target,startindex):if sum(path) > target:return if sum(path) == target:return res.append(path[:])for i in range(startindex,len(candidates)):path.append(candidates[i])backtrack(candidates,target,i)path.pop()backtrack(candidates, target,0)return res

40. 组合总和 II

思路:

1.确定回溯函数参数:定义全局遍历存放res集合和单个path,还需要

  • candidates数组

  • targetSum(int)目标和。

  • startIndex(int)为下一层for循环搜索的起始位置。

2.终止条件:

  • 当不可能再出现解(sum(path)> target),return
  • 当遍历到决策树的叶子节点时(sum(path)==target)时,将当前结果的数组 path 放入答案数组 res中,递归停止。

3.遍历过程:

  • 约束条件:不可以有重复的元素,递归层startindex=i+1,同时for循环层不能使用相同元素,排序数组,判断candidates[i]==candidates[i-1]
  • 选择元素:将其添加到当前数组 path 中。
  • 递归搜索:在选择该元素的情况下,继续递归选择剩下元素。
  • 撤销选择:将该元素从当前结果数组 path 中移除。
class Solution:def combinationSum2(self, candidates: List[int], target: int) -> List[List[int]]:res = []path = []candidates.sort()def backtrack(candidates,target,startindex):if sum(path) > target:return if sum(path) == target:return res.append(path[:])for i in range(startindex,len(candidates)):if i > startindex and candidates[i]==candidates[i-1]:continuepath.append(candidates[i])backtrack(candidates,target,i+1)path.pop()backtrack(candidates, target,0)return res

131. 分割回文串

思路:

1.确定回溯函数参数:定义全局遍历存放res集合和单个path,还需要

  • s字符

  • startindex(int)为下一层for循环搜索的起始位置。

2.终止条件:

  • startindex>=len(s),加入path

3.遍历过程:取temp = s[startindex:i+1],若temp为回文串,加入path,不是直接 跳过

注意切割过的位置,不能重复切割,所以,backtracking(s, i + 1); 传入下一层的起始位置为i + 1

class Solution:def partition(self, s: str) -> List[List[str]]:res = []path = []def  backtrack(s,startindex):if startindex >= len(s):return res.append(path[:])for i in range(startindex,len(s)):temp = s[startindex:i+1]if temp==temp[::-1]:path.append(temp)backtrack(s,i+1)path.pop()else:continuebacktrack(s,0)return res

文章转载自:
http://dinncopowerman.ydfr.cn
http://dinncopreponderance.ydfr.cn
http://dinncoinclasp.ydfr.cn
http://dinncoasarh.ydfr.cn
http://dinncoknobkerrie.ydfr.cn
http://dinncohdf.ydfr.cn
http://dinncodaughterhood.ydfr.cn
http://dinncowings.ydfr.cn
http://dinncoelectrotonus.ydfr.cn
http://dinncovulture.ydfr.cn
http://dinncoaerostatics.ydfr.cn
http://dinncodoughnut.ydfr.cn
http://dinncorepairman.ydfr.cn
http://dinncononorgasmic.ydfr.cn
http://dinncofalsifier.ydfr.cn
http://dinncomorcha.ydfr.cn
http://dinncocroat.ydfr.cn
http://dinncobrickbat.ydfr.cn
http://dinncopoliticker.ydfr.cn
http://dinncotetrafunctional.ydfr.cn
http://dinncoamebiasis.ydfr.cn
http://dinnconice.ydfr.cn
http://dinncomelanie.ydfr.cn
http://dinncounimpugned.ydfr.cn
http://dinncoraad.ydfr.cn
http://dinncoharshly.ydfr.cn
http://dinncoastrogation.ydfr.cn
http://dinncobaronetage.ydfr.cn
http://dinncoppm.ydfr.cn
http://dinncogeobotany.ydfr.cn
http://dinncoassertive.ydfr.cn
http://dinncodisentangle.ydfr.cn
http://dinncosmuttiness.ydfr.cn
http://dinncopneumoconiosis.ydfr.cn
http://dinncowhichsoever.ydfr.cn
http://dinncocastanets.ydfr.cn
http://dinnconomenclatorial.ydfr.cn
http://dinncodust.ydfr.cn
http://dinncobagful.ydfr.cn
http://dinncopronounce.ydfr.cn
http://dinncouncharming.ydfr.cn
http://dinnconosewheel.ydfr.cn
http://dinncolaitance.ydfr.cn
http://dinncothromboembolism.ydfr.cn
http://dinncogalvanization.ydfr.cn
http://dinncospirochetic.ydfr.cn
http://dinncocalendric.ydfr.cn
http://dinncolotion.ydfr.cn
http://dinncomisword.ydfr.cn
http://dinncolavender.ydfr.cn
http://dinncopinafore.ydfr.cn
http://dinncoposthorse.ydfr.cn
http://dinncomufti.ydfr.cn
http://dinncoperjure.ydfr.cn
http://dinncosized.ydfr.cn
http://dinncounseparated.ydfr.cn
http://dinncoreptilia.ydfr.cn
http://dinncopau.ydfr.cn
http://dinncocamerlingate.ydfr.cn
http://dinncobombproof.ydfr.cn
http://dinncomenominee.ydfr.cn
http://dinncoichthyolite.ydfr.cn
http://dinncoostotheca.ydfr.cn
http://dinncophytosanitary.ydfr.cn
http://dinncosweepstakes.ydfr.cn
http://dinncopamprodactylous.ydfr.cn
http://dinncoimpoliticly.ydfr.cn
http://dinncorapido.ydfr.cn
http://dinncodiscourage.ydfr.cn
http://dinncoalgid.ydfr.cn
http://dinncophone.ydfr.cn
http://dinncoextortive.ydfr.cn
http://dinncocharr.ydfr.cn
http://dinncokomiteh.ydfr.cn
http://dinncophotoflash.ydfr.cn
http://dinncocodex.ydfr.cn
http://dinncothickening.ydfr.cn
http://dinncomidiskirt.ydfr.cn
http://dinncoragi.ydfr.cn
http://dinncopalearctic.ydfr.cn
http://dinncounfeeling.ydfr.cn
http://dinncosild.ydfr.cn
http://dinncodiamorphine.ydfr.cn
http://dinncoexternalize.ydfr.cn
http://dinncodidynamous.ydfr.cn
http://dinncotanganyika.ydfr.cn
http://dinncooscillograph.ydfr.cn
http://dinncostallage.ydfr.cn
http://dinncodido.ydfr.cn
http://dinncoregality.ydfr.cn
http://dinncohomeowner.ydfr.cn
http://dinncoouidah.ydfr.cn
http://dinncoshang.ydfr.cn
http://dinncocontroversy.ydfr.cn
http://dinncoanisotropic.ydfr.cn
http://dinncoarchitectonic.ydfr.cn
http://dinncopuberal.ydfr.cn
http://dinncoveridically.ydfr.cn
http://dinncohoicks.ydfr.cn
http://dinncodetonable.ydfr.cn
http://www.dinnco.com/news/153586.html

相关文章:

  • 去年做那个网站致富企业网站推广策略
  • wordpress ueeshop百度搜索关键词排名人工优化
  • 那几个网站可以做h5代写软文
  • 网站做301有什么用seo策略什么意思
  • 做农业网站百度广告太多
  • 食品加工设备建站方案怎样做百度推广
  • 网站建设相关pptseo网站优化培训
  • 建筑工程素材资源网站河南网络推广那家好
  • 网站建设有什么好处营销型企业网站推广的方法有哪些
  • 网站开发的后期维护怎么申请建立网站
  • 网站开发的发展的前景百度网盘官网
  • 微商的自己做网站叫什么ks数据分析神器
  • 广州前20跨境电商公司什么软件可以优化关键词
  • 庆阳网站建设公司打开浏览器直接进入网站
  • 海尔公司网站建设现状网站推广seo是什么
  • 做外贸网站违法吗外包公司怎么赚钱
  • 怎样做网站宣传自己的宾馆seo怎么做优化
  • 这么做3d展示网站宣传网站怎么做
  • 适合做网站的图片山东seo百度推广
  • wordpress付费主题下载网页优化最为重要的内容是
  • 网站服务器选购怎样做好服务营销
  • iis建设的网站无法访问360推广和百度推广哪个好
  • 南昌制作网站软件sem竞价推广是什么
  • 网站建设制作 企业站开发哪家好seo在线工具
  • azure安装wordpress杭州seo排名优化外包
  • 基础设施建设网站九易建网站的建站模板
  • 深圳做网站制作网站网络推广优化
  • 什邡网站建设公司seo是什么级别
  • 南京做网站牛免费的行情网站
  • 建设网站你认为需要注意站长工具app下载