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

网站托管流程宽屏大气企业网站源码

网站托管流程,宽屏大气企业网站源码,网站制作公司怎么赚钱,做+淘宝客最大的网站是叫什么回溯 1、39. 组合总和 题目#xff1a; 给你一个 无重复元素 的整数数组 candidates 和一个目标整数 target #xff0c;找出 candidates 中可以使数字和为目标数 target 的 所有 不同组合 #xff0c;并以列表形式返回。你可以按 任意顺序 返回这些组合。 candidates 中的…回溯 1、39. 组合总和 题目 给你一个 无重复元素 的整数数组 candidates 和一个目标整数 target 找出 candidates 中可以使数字和为目标数 target 的 所有 不同组合 并以列表形式返回。你可以按 任意顺序 返回这些组合。 candidates 中的 同一个 数字可以 无限制重复被选取 。如果至少一个数字的被选数量不同则两种组合是不同的。 对于给定的输入保证和为 target 的不同组合数少于 150 个。 输入candidates [2,3,6,7], target 7 输出[[2,2,3],[7]] 思路 第二次写了很简单就写出来了注意 2 可以使用多次。_backtrack(res, list,candidates, target,sum, i1),不要i1 func combinationSum(candidates []int, target int) [][]int {// 代码二刷很经典回溯list : make([]int, 0)res : make([][]int, 0)backtrack(res, list,candidates,target,0,0)return res } func backtrack(res *[][]int, list,candidates []int, target, sum,index int) {if sum target {ans : make([]int, len(list))copy(ans, list)*res append(*res, ans)return}if sum target {return}for i : index; ilen(candidates); i {sum candidates[i]list append(list, candidates[i])backtrack(res, list,candidates, target,sum, i)sum - candidates[i]list list[:len(list)-1]} }2、40. 组合总和 II 题目 给定一个候选人编号的集合 candidates 和一个目标数 target 找出 candidates 中所有可以使数字和为 target 的组合。 candidates 中的每个数字在每个组合中只能使用 一次 。 注意解集不能包含重复的组合。 输入: candidates [10,1,2,7,6,1,5], target 8, 输出: [ [1,1,6], [1,2,5], [1,7], [2,6] ] 思路 怎么去重呢?使用 historyelse if sum target 记得这个也要剪枝避免无效运算导致的超时 func combinationSum2(candidates []int, target int) [][]int {// 代码二刷sort.Ints(candidates)history : make([]bool, len(candidates))list : make([]int, 0)res : make([][]int, 0)backtrack(res, list,candidates,target,0,0,history)return res } func backtrack(res *[][]int, list, candidates []int, target, index, sum int,history []bool) {if sum target {ans : make([]int, len(list))copy(ans, list)*res append(*res, ans)return} else if sum target {return}for i:index; ilen(candidates); i {if i1 candidates[i] candidates[i-1] history[i-1] false {continue}sum candidates[i]list append(list, candidates[i])history[i] truebacktrack(res, list, candidates, target, i1, sum,history)sum - candidates[i]list list[:len(list)-1]history[i] false} }3、131. 分割回文串 题目 给你一个字符串 s请你将 s 分割成一些子串使每个子串都是 回文串 。返回 s 所有可能的分割方案。 回文串 是正着读和反着读都一样的字符串。 输入s “aab” 输出[[“a”,“a”,“b”],[“aa”,“b”]] 思路 细节注意i:index注意其实回文很简单带入例子就明白了*res append(*res, ans)注意是 ans为什么呢 func partition(s string) [][]string {// 代码二刷条件就是判断是否为回文字符串list : make([]string, 0)res : make([][]string, 0)backtrack(res, list, s, 0)return res } func backtrack(res *[][]string, list []string, s string, index int) {if index len(s) {ans : make([]string, len(list))copy(ans, list)*res append(*res, ans)return}for i:index; ilen(s); i {if huiwen(s, index, i) {list append(list, s[index:i1])backtrack(res, list, s, i1)list list[:len(list)-1]}} } func huiwen(s string, left,right int) bool {for leftright {if s[left] ! s[right] {return false}leftright--}return true }
http://www.pierceye.com/news/501503/

相关文章:

  • 阿里云增加网站wordpress前台后台都空白
  • 做网站商城要注册什么公司建行官网官网网站吗
  • 国外做meta分析的网站wordpress 下载文件插件
  • 济南城市建设集团网站陕西网
  • 专业的网站设计制作怎么建正规网站
  • 用安卓做网站php网站开发系统
  • 58同城网站建设的不足网站前台代码
  • 网站建设销售人员培训教程长兴县建设局网站
  • 用vue框架做的pc端网站wordpress改造论坛
  • 大庆建设网站首页中国寰球工程有限公司网站设计
  • 免费搭建贴吧系统网站js做网站框架
  • 泰安如何选择网站建设网盘 商业网站建设案例课程 下载
  • 可信赖的邵阳网站建设动漫设计属于什么大类
  • 西安网站排名优化网站设计用什么软件实现
  • 网站注册页面模板html5教程百度云
  • 深圳装饰公司前十强佛山seo优化电话
  • 广东阳春市建设局网站做手机网站的重要性
  • 设置网站的关键词自己做网站有什么用
  • 做那个网站比较好百度百科优化排名
  • 好发信息网站建设新闻今天最新消息
  • 邮件服务器是不是网站服务器河南住房和城乡建设网站
  • 微网站管理平台网站连锁店查询怎么做
  • 网域高科学校网站管理系统企业融资以什么为基础
  • 百度网站改版工具提高网站安全性
  • 科技网站推荐南宁百度seo
  • 设计婚纱网站wordpress主题制作全过程新手必看
  • 郑州网站seo厂家上海制作网页的公司有哪些
  • 网站修改关键词不收录vps 可以做多个网站吗
  • 营销外包网站App加网站什么做
  • 网页设计网站制作视频教程重庆是哪个省份