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

网站上线后的工作怎么在网上做广告

网站上线后的工作,怎么在网上做广告,定制家具如何选择,做电棍网站问题背景 给定一个候选人编号的集合 c a n d i d a t e s candidates candidates 和一个目标数 t a r g e t target target,找出 c a n d i d a t e s candidates candidates 中所有可以使数字和为 t a r g e t target target 的组合。 c a n d i d a t e s c…

问题背景

给定一个候选人编号的集合 c a n d i d a t e s candidates candidates 和一个目标数 t a r g e t target target,找出 c a n d i d a t e s candidates candidates 中所有可以使数字和为 t a r g e t target target 的组合。
c a n d i d a t e s candidates candidates 中的每个数字在每个组合中只能使用 一次
注意:解集不能包含重复的组合。

数据约束

  • 1 ≤ c a n d i d a t e s . l e n g t h ≤ 100 1 \le candidates.length \le 100 1candidates.length100
  • 1 ≤ c a n d i d a t e s [ i ] ≤ 50 1 \le candidates[i] \le 50 1candidates[i]50
  • 1 ≤ t a r g e t ≤ 30 1 \le target \le 30 1target30

解题过程

算是回溯的例题,由于结果不能重复,要先将数组进行排序,方便在过程中跳已经处理过的相等元素。

具体实现

递归

class Solution {public List<List<Integer>> combinationSum2(int[] candidates, int target) {Arrays.sort(candidates);List<List<Integer>> res = new ArrayList<>();List<Integer> path = new ArrayList<>();dfs(0, target, candidates, res, path);return res;}private void dfs(int i, int target, int[] candidates, List<List<Integer>> res, List<Integer> path) {if(target == 0) {res.add(new ArrayList(path));return;}if(i == candidates.length) {return;}int cur = candidates[i];if(target < cur) {return;}path.add(cur);dfs(i + 1, target - cur, candidates, res, path);path.remove(path.size() - 1);i++;while(i < candidates.length && candidates[i] == cur) {i++;}dfs(i, target, candidates, res, path);}
}

递推

class Solution {public List<List<Integer>> combinationSum2(int[] candidates, int target) {Arrays.sort(candidates);List<List<Integer>> res = new ArrayList<>();List<Integer> path = new ArrayList<>();dfs(0, target, candidates, res, path);return res;}private void dfs(int i, int target, int[] candidates, List<List<Integer>> res, List<Integer> path) {if(target == 0) {res.add(new ArrayList<>(path));return;}for (int j = i; j < candidates.length && candidates[j] <= target; j++) {if(j > i && candidates[j] == candidates[j - 1]) {continue;}path.add(candidates[j]);dfs(j + 1, target - candidates[j], candidates, res, path);path.remove(path.size() - 1);}}
}
http://www.skylitedrivein.com/news/505.html

相关文章:

  • 做网站在哪里租服务器单页网站模板
  • 外贸网站seo推广上海百度推广电话客服
  • 营销方案网站电子商务网站建设论文
  • 网站开发用什么系统上海网络推广排名公司
  • 网站建设制作 南京公司百度seo关键词点击软件
  • 网站建设 鄂icp备什么叫软文推广
  • 郑州个人做网站网络推广合作资源平台
  • 学校网站栏目建设百度app安装
  • 深圳商城网站建设公司aso优化吧
  • 手机app网站竞价排名的弊端
  • 乌鲁木齐全网建站360推广官网
  • 做域名代理网站企业网站建设目标
  • h5 和手机网站最近七天的新闻重点
  • 番禺手机网站建设企业网页设计与推广
  • 用nodejs可以做网站么超云seo优化
  • 宁波建设网 提取业务长春seo公司
  • 网站制作公司怎么运营今日头条新闻消息
  • 诱导视频网站怎么做南宁网站seo优化公司
  • 静态网站 搜索功能郑州网站推广优化
  • 网站建设pdf下载免费网站推广群发软件
  • 购物网站的页面设计网页制作与设计
  • 国内做任务得数字货币的网站上海百度seo牛巨微
  • 平面设计主要学什么哪些软件网站seo方案模板
  • 郑东新区网站建设网站推广方法大全
  • wordpress 高级自定义seo工作流程
  • 网站制作公司获取客户谷歌浏览器官方正版下载
  • 网站建设代码模板百度关键词优化快速排名软件
  • 韩国风格网站php源码友情链接建立遵循的原则包括
  • 做优惠券的网站有哪些软文推荐
  • 今天的新闻联播文字版东莞百度推广优化公司