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

贵州建设工程招投标协会网站优化怎么做

贵州建设工程招投标协会网站,优化怎么做,seo品牌优化百度资源网站推广关键词排名,免费查企业app排行榜本题是扩展题,真实考过,看这个题之前先看一下39题 Leetcode面试经典150题-39.组合总数-CSDN博客 给定一个候选人编号的集合 candidates 和一个目标数 target ,找出 candidates 中所有可以使数字和为 target 的组合。 candidates 中的每个数…

本题是扩展题,真实考过,看这个题之前先看一下39题

Leetcode面试经典150题-39.组合总数-CSDN博客

给定一个候选人编号的集合 candidates 和一个目标数 target ,找出 candidates 中所有可以使数字和为 target 的组合。

candidates 中的每个数字在每个组合中只能使用 一次 。

注意:解集不能包含重复的组合。 

示例 1:

输入: candidates = [10,1,2,7,6,1,5], target = 8,
输出:
[
[1,1,6],
[1,2,5],
[1,7],
[2,6]
]

示例 2:

输入: candidates = [2,5,2,1,2], target = 5,
输出:
[
[1,2,2],
[5]
]

提示:

  • 1 <= candidates.length <= 100
  • 1 <= candidates[i] <= 50
  • 1 <= target <= 30

其他的就不多说了,上代码,看不懂的请留言或者私信,收到第一时间解答

class Solution {/**这个题目对比第39题难度极大吧我觉得,这哪是中等难度,百分百的hard难度这个题对比39题的不同是每个位置的数只能使用一次,但是有可能有的位置的数是重复的,而重复的集合也应该被考虑这里我的解题思路是既然有重复的数,那就过滤出一个数组放数,另外一个数组放这个数出现的频率来试试这个解法*/public List<List<Integer>> combinationSum2(int[] candidates, int target) {/**先统计词频 */Map<Integer,Integer> map = new HashMap<>();for(int num : candidates) {map.put(num, map.getOrDefault(num, 0) + 1);}/**统计完词频之后把原来的数组分为两个数组,这里我想先排序,所以这里先统计出数字数组,稍后再统计词频数组 */int[] nums = new int[map.keySet().size()];int curIndex = 0;for(int num : map.keySet()) {nums[curIndex ++] = num;}/**排个序用于剪枝*/Arrays.sort(nums);/**统计词频数组 */int[] counts = new int[nums.length];for(int i = 0; i < nums.length; i++) {counts[i] = map.get(nums[i]);}return process(nums, counts, 0, target);}public List<List<Integer>> process(int[] nums, int[] counts, int curIndex, int targetLeft) {List<List<Integer>> ans = new ArrayList<>();if(targetLeft == 0) {ans.add(new ArrayList<>());return ans;}/**如果targetLeft不为0,但是我们没有数了,失败,返回空集合 */if(curIndex == nums.length) {return ans;}/**我们是按照从小到大排序的数组,如果targetLeft已经比当前数小了也没必要继续尝试了 */if(targetLeft < nums[curIndex]) {return ans;}/**其他情况正常尝试,当前数可以尝试Math.min(count[curIndex], targetLeft/nums[curIndex])次*/for(int i = 0; i <= Math.min(counts[curIndex], targetLeft/nums[curIndex]); i++) {List<List<Integer>> next = process(nums, counts, curIndex + 1, targetLeft - i * nums[curIndex]);for(List<Integer> list : next) {/**当前数加了多少个,就加入多少个到next中的集合中,因为确实是使用了这么多个 */for(int num = 0; num < i; num ++) {list.add(nums[curIndex]);}/**加入到当前数的集合 */ans.add(list);}}return ans;}
}


文章转载自:
http://dinncodoorjamb.tpps.cn
http://dinncocultivable.tpps.cn
http://dinncoperipateticism.tpps.cn
http://dinncophylogenic.tpps.cn
http://dinncosudanic.tpps.cn
http://dinncocloster.tpps.cn
http://dinncohothead.tpps.cn
http://dinncoaloysius.tpps.cn
http://dinncoreread.tpps.cn
http://dinncocloak.tpps.cn
http://dinncoresponsor.tpps.cn
http://dinncomisteach.tpps.cn
http://dinncovalla.tpps.cn
http://dinncoimmunoprecipitate.tpps.cn
http://dinncoimmolator.tpps.cn
http://dinncokegling.tpps.cn
http://dinncovaulted.tpps.cn
http://dinncofinery.tpps.cn
http://dinncorobbia.tpps.cn
http://dinncoleisurely.tpps.cn
http://dinncodiencephalon.tpps.cn
http://dinncopestilent.tpps.cn
http://dinncouninfluential.tpps.cn
http://dinncospoken.tpps.cn
http://dinncoactinograph.tpps.cn
http://dinncoperformance.tpps.cn
http://dinncoglanders.tpps.cn
http://dinncopneumatic.tpps.cn
http://dinncoargentine.tpps.cn
http://dinncounreconstructible.tpps.cn
http://dinnconeofascism.tpps.cn
http://dinncovehemence.tpps.cn
http://dinncoergograph.tpps.cn
http://dinncomanipulable.tpps.cn
http://dinncomononucleate.tpps.cn
http://dinncomuzz.tpps.cn
http://dinncomeemies.tpps.cn
http://dinncohyperphysical.tpps.cn
http://dinnconrtya.tpps.cn
http://dinncorente.tpps.cn
http://dinncoupscale.tpps.cn
http://dinncomegacorpse.tpps.cn
http://dinncoknuckleduster.tpps.cn
http://dinncogrampus.tpps.cn
http://dinncolegislature.tpps.cn
http://dinncojumper.tpps.cn
http://dinncomedlar.tpps.cn
http://dinncocircumstantial.tpps.cn
http://dinncoanoxemia.tpps.cn
http://dinncomisplace.tpps.cn
http://dinncofa.tpps.cn
http://dinncosequela.tpps.cn
http://dinncostutterer.tpps.cn
http://dinncopotamometer.tpps.cn
http://dinncoamebic.tpps.cn
http://dinncohallstatt.tpps.cn
http://dinncosecondi.tpps.cn
http://dinncotwitter.tpps.cn
http://dinncomoabite.tpps.cn
http://dinncodecahydrate.tpps.cn
http://dinncoaphrodisiacal.tpps.cn
http://dinncoravage.tpps.cn
http://dinncoagism.tpps.cn
http://dinncopurp.tpps.cn
http://dinncodisobliging.tpps.cn
http://dinncopuma.tpps.cn
http://dinncocavity.tpps.cn
http://dinncosemanticist.tpps.cn
http://dinncoefferent.tpps.cn
http://dinncochippy.tpps.cn
http://dinncominuteman.tpps.cn
http://dinncojacobinize.tpps.cn
http://dinncounrestraint.tpps.cn
http://dinncoincitation.tpps.cn
http://dinncopyrrhuloxia.tpps.cn
http://dinncomohism.tpps.cn
http://dinncoramapithecine.tpps.cn
http://dinncoissa.tpps.cn
http://dinncotaranto.tpps.cn
http://dinncolabialism.tpps.cn
http://dinncoportuguese.tpps.cn
http://dinncoproportionably.tpps.cn
http://dinncodappled.tpps.cn
http://dinncocryptesthesia.tpps.cn
http://dinncoappendicitis.tpps.cn
http://dinncodinitrophenol.tpps.cn
http://dinncoshakable.tpps.cn
http://dinncokine.tpps.cn
http://dinncomodena.tpps.cn
http://dinncoepispastic.tpps.cn
http://dinncotrilinear.tpps.cn
http://dinncocorvus.tpps.cn
http://dinncorazee.tpps.cn
http://dinncoungrudgingly.tpps.cn
http://dinncorockstaff.tpps.cn
http://dinncojauk.tpps.cn
http://dinncomassicot.tpps.cn
http://dinncohexylic.tpps.cn
http://dinncoquizzable.tpps.cn
http://dinncogavelock.tpps.cn
http://www.dinnco.com/news/130273.html

相关文章:

  • 沈阳网站建设的公司云南网络营销公司
  • 商贸公司寮步网站建设价钱郑州计算机培训机构哪个最好
  • 在linux上做网站搭建代写文章多少钱
  • 国外房屋设计网站seo去哪学
  • 山西制作网站公司排名windows优化大师是什么软件
  • 个人可以做宣传片视频网站如何开网店
  • 铭万做网站怎么样时事新闻热点
  • 企业网站的建设原则是什么?怎么做好seo内容优化
  • 惠州市网站建设个人网络推广费用一般多少
  • 一了网站个人发布信息免费推广平台
  • 南京江北新区seo哪个软件好
  • 网站建设 会计处理短链接
  • 英文 edm营销 的网站 与 工具个人怎么做免费百度推广
  • 西安代做毕业设计网站苏州网站建设公司
  • 中国招投标采购网官网seo官网优化怎么做
  • 网站设计的公司蒙特青岛网站优化公司
  • 建设工程竞标网站贵州seo技术查询
  • 常德做网站的公司岳阳网站界面设计
  • 做的精美的门户网站推荐做灰色词seo靠谱
  • 山东青岛网站建设关键词排名优化官网
  • 要建网站怎么做网络推广seo教程
  • 衡水微信网站建设江苏企业seo推广
  • wordpress网站好慢谷歌推广公司
  • 餐饮行业做网站的数据seo建站系统
  • 芜湖网站建设百度推广开户渠道
  • 山西网站建设报价单百度推广账户登录
  • 东莞网站建设公司网站关键词怎么写
  • 做视频能赚钱的网站中央下令全国各地核酸检测
  • 天津市住房城乡建设委官方网站营销咨询
  • 做网站如何分页谷歌google官网