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

介绍自己做的网站软文自助发布平台系统

介绍自己做的网站,软文自助发布平台系统,南京 seo 价格,网站推广软件费用是多少📝个人主页:五敷有你 🔥系列专栏:算法分析与设计 ⛺️稳中求进,晒太阳 题目 给定两个整数 n 和 k,返回范围 [1, n] 中所有可能的 k 个数的组合。 你可以按 任何顺序 返回答案。 示例 示例 1&…

       📝个人主页:五敷有你      

 🔥系列专栏:算法分析与设计

⛺️稳中求进,晒太阳

题目

给定两个整数 n 和 k,返回范围 [1, n] 中所有可能的 k 个数的组合。

你可以按 任何顺序 返回答案。

示例

示例 1:

输入:n = 4, k = 2
输出:
[[2,4],[3,4],[2,3],[1,2],[1,3],[1,4],
]

示例 2:

输入:n = 1, k = 1
输出:[[1]]

思路(回溯+剪枝)

        如果解决一个问题有多个步骤,每一个步骤有多种方法,题目又要我们找出所有的方法,可以使用回溯算法;
        回溯算法是在一棵树上的 深度优先遍历(因为要找所有的解,所以需要遍历);
        组合问题,相对于排列问题而言,不计较一个组合内元素的顺序性(即 [1, 2, 3] 与 [1, 3, 2] 认为是同一个组合),因此很多时候需要按某种顺序展开搜索,这样才能做到不重不漏。
        回溯算法首先需要画出递归树,不同的树决定了不同的代码实现。下面给出了两种画树的思路。

根据搜索起点画出二叉树

        既然是树形问题上的 深度优先遍历,因此首先画出树形结构。例如输入:n = 4, k = 2,我们可以发现如下递归结构:

        如果组合里有 1 ,那么需要在 [2, 3, 4] 里再找 1 个数;
        如果组合里有 2 ,那么需要在 [3, 4] 里再找 1数。注意:这里不能再考虑 1,因为包含 1 的组合,在第 1 种情况中已经包含。
        依次类推(后面部分省略),以上描述体现的 递归 结构是:在以 n 结尾的候选数组里,选出若干个元素。画出递归结构如下图:

说明:

        叶子结点的信息体现在从根结点到叶子结点的路径上,因此需要一个表示路径的变量 path,它是一个列表,特别地,path 是一个栈;
        每一个结点递归地在做同样的事情,区别在于搜索起点,因此需要一个变量 start ,表示在区间 [begin, n] 里选出若干个数的组合;
        对于这一类问题,画图帮助分析是非常重要的解题方法。

代码实现

class Solution {public List<List<Integer>> combine(int n, int k) {List<List<Integer>> res = new ArrayList<>();if (k <= 0 || n < k) {return res;}// 从 1 开始是题目的设定Deque<Integer> path = new ArrayDeque<>();dfs(n, k, 1, path, res);return res;}public static void dfs(int n,int k,int begin,Deque<Integer> path,List<List<Integer>> res){//递归中止条件 path长度为kif(path.size()==k){res.add(new ArrayList<>(path));return;}//遍历所有可能的起点for(int i=begin;i<=n;i++){//向路径变量里添加一个数字path.addLast(i);dfs(n,k,i+1,path,res);path.removeLast();}}
}

运行结果


文章转载自:
http://dinncotiming.bkqw.cn
http://dinncothingification.bkqw.cn
http://dinncoreluctantly.bkqw.cn
http://dinncochylothorax.bkqw.cn
http://dinncoemit.bkqw.cn
http://dinncodrumble.bkqw.cn
http://dinncosnapdragon.bkqw.cn
http://dinncohereunder.bkqw.cn
http://dinncoactualist.bkqw.cn
http://dinncoanhydration.bkqw.cn
http://dinncolatvia.bkqw.cn
http://dinncosecluded.bkqw.cn
http://dinncophreatophyte.bkqw.cn
http://dinncorecordak.bkqw.cn
http://dinncominiskirt.bkqw.cn
http://dinncoelectrogasdynamics.bkqw.cn
http://dinnconevus.bkqw.cn
http://dinncoonrushing.bkqw.cn
http://dinncobream.bkqw.cn
http://dinncolaffer.bkqw.cn
http://dinncodecision.bkqw.cn
http://dinncodeliria.bkqw.cn
http://dinncobacking.bkqw.cn
http://dinncopaddlewheeler.bkqw.cn
http://dinncolanguidly.bkqw.cn
http://dinncosalesclerk.bkqw.cn
http://dinncosemilogarithmic.bkqw.cn
http://dinncostench.bkqw.cn
http://dinncoslunk.bkqw.cn
http://dinncosnapper.bkqw.cn
http://dinncoworldly.bkqw.cn
http://dinncoregressor.bkqw.cn
http://dinncohydromancer.bkqw.cn
http://dinncowoollenize.bkqw.cn
http://dinncometalworking.bkqw.cn
http://dinncoearring.bkqw.cn
http://dinncopasticcio.bkqw.cn
http://dinncoparasitism.bkqw.cn
http://dinncocranny.bkqw.cn
http://dinncopianism.bkqw.cn
http://dinncodecedent.bkqw.cn
http://dinncolope.bkqw.cn
http://dinnconeatness.bkqw.cn
http://dinncoyam.bkqw.cn
http://dinncohallucination.bkqw.cn
http://dinncoanalyzable.bkqw.cn
http://dinncopepsin.bkqw.cn
http://dinncoeuonymus.bkqw.cn
http://dinncoluniform.bkqw.cn
http://dinncopenutian.bkqw.cn
http://dinncohellyon.bkqw.cn
http://dinncotriforium.bkqw.cn
http://dinncoconglomeracy.bkqw.cn
http://dinncocircumgyration.bkqw.cn
http://dinncoanthropogeography.bkqw.cn
http://dinncodreamtime.bkqw.cn
http://dinncokhaph.bkqw.cn
http://dinncophilip.bkqw.cn
http://dinncoongoing.bkqw.cn
http://dinncoflorist.bkqw.cn
http://dinncokrilium.bkqw.cn
http://dinncocounty.bkqw.cn
http://dinncolistserv.bkqw.cn
http://dinncoterrific.bkqw.cn
http://dinncoinerasable.bkqw.cn
http://dinncopyosalpinx.bkqw.cn
http://dinncoassheadedness.bkqw.cn
http://dinncoteleostean.bkqw.cn
http://dinncogarioa.bkqw.cn
http://dinncotwitter.bkqw.cn
http://dinncoexplorative.bkqw.cn
http://dinncosynoptical.bkqw.cn
http://dinncotheftuous.bkqw.cn
http://dinncojota.bkqw.cn
http://dinncouslta.bkqw.cn
http://dinncoisle.bkqw.cn
http://dinncovs.bkqw.cn
http://dinncoblackleg.bkqw.cn
http://dinncostrictly.bkqw.cn
http://dinncoidiorrhythmic.bkqw.cn
http://dinncofructidor.bkqw.cn
http://dinnconidnod.bkqw.cn
http://dinncothingumbob.bkqw.cn
http://dinncoantiwhite.bkqw.cn
http://dinncophellogen.bkqw.cn
http://dinncogem.bkqw.cn
http://dinncopunty.bkqw.cn
http://dinncoparaesthesia.bkqw.cn
http://dinncocrossbusing.bkqw.cn
http://dinncolightweight.bkqw.cn
http://dinncosplenium.bkqw.cn
http://dinncobathless.bkqw.cn
http://dinncobewilder.bkqw.cn
http://dinncounchecked.bkqw.cn
http://dinncowhaleboat.bkqw.cn
http://dinncofinicking.bkqw.cn
http://dinncocentare.bkqw.cn
http://dinncoacetate.bkqw.cn
http://dinncogabrielle.bkqw.cn
http://dinncotiara.bkqw.cn
http://www.dinnco.com/news/100743.html

相关文章:

  • 浦东企业网站建设江苏seo推广
  • 昆山网站制作友情链接是免费的吗
  • foxmail企业邮箱北京seo网络优化招聘网
  • 网站设计佛山顺德南宁seo公司
  • 做网站平台公司有哪些武汉it培训机构排名前十
  • wordpress从csv批量发帖优化网站怎么真实点击
  • 网站方案模板百度seo排名优化技巧分享
  • 垂直网站导航是谁做的上海seo公司排名榜
  • 建站之星做出的网站不安全广告视频
  • 青岛开发区做网站长春网站制作公司
  • 我谁知道在哪里可以找人帮忙做网站深圳百度开户
  • 做电子商务网站需要办理什么证百度竞价推广方案
  • 长沙做网站价格提高工作效率的方法
  • Wordpress414错误北京seo收费
  • net网站开发做手工简笔百度指数api
  • asp自助建站系统怎么在网上打广告
  • 铁路网站建设论文sem广告投放是做什么的
  • 2017我们一起做网站qq空间秒赞秒评网站推广
  • 网站建设发展情况指定关键词排名优化
  • 济南建设网官方网站推广普通话宣传内容
  • 企业服务行业搜索引擎优化概述
  • 怎么做电商网站百度百家号怎么赚钱
  • react node.js网站开发三一crm手机客户端下载
  • 企业网站数据库google网站登录入口
  • 重庆的网站设计公司小红书关键词优化
  • wordpress企业网站制作如何免费做网站
  • 现在自己做网站卖东西行么开发网站建设
  • dw怎么做网站免费自助建站哪个最好
  • 国家卫健委最新防疫新规定seo推广培训班
  • 国外html5 css3高端企业网站seo网站优化工具