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

沧州建设厅官方网站什么是网络营销的微观环境

沧州建设厅官方网站,什么是网络营销的微观环境,wordpress 论坛,免费crm网站不用下载的软件39.组合总和 思路#xff1a; 1.确定回溯函数参数#xff1a;定义全局遍历存放res集合和单个path#xff0c;还需要 candidates数组 targetSum#xff08;int#xff09;目标和。 startIndex#xff08;int#xff09;为下一层for循环搜索的起始位置。 2.终止条件…39.组合总和 思路 1.确定回溯函数参数定义全局遍历存放res集合和单个path还需要 candidates数组 targetSumint目标和。 startIndexint为下一层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 res40. 组合总和 II 思路 1.确定回溯函数参数定义全局遍历存放res集合和单个path还需要 candidates数组 targetSumint目标和。 startIndexint为下一层for循环搜索的起始位置。 2.终止条件 当不可能再出现解(sum(path) target)return当遍历到决策树的叶子节点时(sum(path)target)时将当前结果的数组 path 放入答案数组 res中递归停止。 3.遍历过程 约束条件不可以有重复的元素递归层startindexi1同时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,i1)path.pop()backtrack(candidates, target,0)return res131. 分割回文串 思路 1.确定回溯函数参数定义全局遍历存放res集合和单个path还需要 s字符 startindexint为下一层for循环搜索的起始位置。 2.终止条件 startindexlen(s)加入path 3.遍历过程取temp s[startindex:i1]若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:i1]if temptemp[::-1]:path.append(temp)backtrack(s,i1)path.pop()else:continuebacktrack(s,0)return res
http://www.hkea.cn/news/14346594/

相关文章:

  • 投简历网站镇江网站建设找思创
  • 模板下载网站织梦模板郑州好的妇科医院排行
  • 佛山网站建设公司88wordpress图片链接插件
  • 桂林象鼻山附近的酒店seo是什么的简称
  • html个人网站策划书做网站第三方
  • 网站做专题主题该怎么选广东省城乡与住房建设厅网站
  • 网站做中文和英文切换wordpress 下载模块
  • 旅游集团网站建设建网站专用网站
  • 游戏代理是怎么赚钱的如何代理游戏大连企业网站排名优化
  • 网站后期维护收费育婴网站模板
  • 做百度推广网站找谁好建设网站的准备工作
  • 建设一批适合青少年的网站哪个网站做ppt好
  • 渭南定制网站建设公司长沙网络科技有限公司
  • 建设银行光明支行网站个人养老保险查询
  • 网站美化怎么做app小程序软件定制开发
  • 石家庄市栾城区建设局网站农业电商平台有哪些
  • 网站风格评价怎么设置iis默认网站
  • 携程旅行网站建设分析广州市建设招标管理办公室网站
  • 网站制作专家营销型网站建设要多少钱
  • 有专门做辩论的网站吗国家信用信息企业公示网官网
  • 昌平区手机网站制作服务国内最近重大新闻2024
  • 怎么查网站开发的语言网站如何添加外链
  • 博客用来做微网站网上国网app推广经验
  • 网站风格设计的选择做网站怎么添加背景图片
  • 大尺度做爰网站在线成都微信小程序开发平台
  • 智能建站收费标准岚庭装饰公司口碑怎么样
  • 凡高网站建设宠物网站建设策划方案
  • 网站开发项目外包宁夏建网站报价
  • 网站可以用cdr做吗阜蒙县建设学校官网网站
  • 网站建设与网页制作的实验目的阜宁城乡建设局网站