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

毕业设计做啥网站好成都网站seo推广

毕业设计做啥网站好,成都网站seo推广,wordpress personal主题,品牌建设的核心跳跃游戏|| 给定一个长度为 n 的 0 索引整数数组 nums。初始位置为 nums[0]。 每个元素 nums[i] 表示从索引 i 向前跳转的最大长度。换句话说&#xff0c;如果你在 nums[i] 处&#xff0c;你可以跳转到任意 nums[i j] 处: 0 < j < nums[i] i j < n 返回到达 num…

跳跃游戏||

给定一个长度为 n 的 0 索引整数数组 nums。初始位置为 nums[0]

每个元素 nums[i] 表示从索引 i 向前跳转的最大长度。换句话说,如果你在 nums[i] 处,你可以跳转到任意 nums[i + j] 处:

  • 0 <= j <= nums[i] 
  • i + j < n

返回到达 nums[n - 1] 的最小跳跃次数。生成的测试用例可以到达 nums[n - 1]

示例 1:

输入: nums = [2,3,1,1,4]
输出: 2
解释: 跳到最后一个位置的最小跳跃数是 2从下标为 0 跳到下标为 1 的位置,跳1步,然后跳3步到达数组的最后一个位置。

示例 2:

输入: nums = [2,3,0,1,4]
输出: 2

实现思路:

与昨天所写的跳跃游戏这一题一样,这个问题是一个典型的贪心算法问题,但是难度稍微不同,没做过的可以去看看。要解决这个问题,你可以从左到右遍历数组,并使用一个变量来跟踪当前能够达到的最远位置。

以下是解决这个问题的算法步骤:

  1. 初始化两个变量,maxReach 表示当前可以达到的最远下标,初始值为 0,因为最开始你位于第一个下标。
  2. 初始化另一个变量 end 表示当前考虑的下标,初始值也为 0。
  3. 初始化一个变量 step 来记录到达终点所需的最小跳跃次数,初始值为 0。
  4. 遍历数组 nums 从下标 0 开始:
    • 在每一步,更新 maxReach 为 max(maxReach, end + nums[end]),即当前最远位置与当前下标加上可以跳跃的最大长度中的较大值。
    • 如果 maxReach 大于或等于 n - 1(数组的最后一个下标),则说明可以到达终点,此时增加 step 并结束循环。
    • 如果没有到达终点,将 end 向前移动到 maxReach,表示下一次跳跃的起始点是当前能够达到的最远位置。
  5. 在循环结束后,返回 step 作为结果。

实现代码:

public int jump(int[] nums) {int maxReach = 0; // 当前可以到达的最远下标int end = 0;      // 当前考虑的下标int step = 0;     // 到达终点所需的最小跳跃次数for (int i = 0; i < nums.length - 1; i++) {maxReach = Math.max(maxReach, i + nums[i]); // 更新最远下标if (maxReach >= nums.length - 1) { // 如果可以到达终点step++; // 增加跳跃次数break;   // 结束循环}if (i == end) { // 如果当前下标是之前跳跃的最远下标step++; // 增加跳跃次数end = maxReach; // 更新下一次跳跃的起始点}}return step;
}


文章转载自:
http://dinncomodularization.wbqt.cn
http://dinncounbudging.wbqt.cn
http://dinncojoyride.wbqt.cn
http://dinncomatamoros.wbqt.cn
http://dinncokingpin.wbqt.cn
http://dinncoibsenian.wbqt.cn
http://dinncotrick.wbqt.cn
http://dinncocarnation.wbqt.cn
http://dinncogondoletta.wbqt.cn
http://dinncocognate.wbqt.cn
http://dinncorosaniline.wbqt.cn
http://dinncodamagingly.wbqt.cn
http://dinncounwatered.wbqt.cn
http://dinncomoonbow.wbqt.cn
http://dinncoendurance.wbqt.cn
http://dinncohoarding.wbqt.cn
http://dinncosinecure.wbqt.cn
http://dinncoforficulate.wbqt.cn
http://dinncomarty.wbqt.cn
http://dinncominimum.wbqt.cn
http://dinncotog.wbqt.cn
http://dinncotumultuously.wbqt.cn
http://dinncoblear.wbqt.cn
http://dinncoultraminiature.wbqt.cn
http://dinncomyoglobin.wbqt.cn
http://dinncoalderney.wbqt.cn
http://dinncoantianxiety.wbqt.cn
http://dinncopermanent.wbqt.cn
http://dinncogelatinate.wbqt.cn
http://dinncointerrelated.wbqt.cn
http://dinncorepertoire.wbqt.cn
http://dinncotwyer.wbqt.cn
http://dinncopseudosalt.wbqt.cn
http://dinncokotwalee.wbqt.cn
http://dinncorhinencephalic.wbqt.cn
http://dinncodereism.wbqt.cn
http://dinncogheber.wbqt.cn
http://dinncohootch.wbqt.cn
http://dinncotasset.wbqt.cn
http://dinncoroadstead.wbqt.cn
http://dinncospinster.wbqt.cn
http://dinncohenhouse.wbqt.cn
http://dinncoswitch.wbqt.cn
http://dinncomoral.wbqt.cn
http://dinncoloadability.wbqt.cn
http://dinncohepatocele.wbqt.cn
http://dinncodisbandment.wbqt.cn
http://dinncosulphane.wbqt.cn
http://dinncoamericana.wbqt.cn
http://dinncocaveatee.wbqt.cn
http://dinncoexuvial.wbqt.cn
http://dinncothyroidotomy.wbqt.cn
http://dinncometallic.wbqt.cn
http://dinncobiochemic.wbqt.cn
http://dinncomien.wbqt.cn
http://dinncotilefish.wbqt.cn
http://dinncoexterminator.wbqt.cn
http://dinncoterpsichorean.wbqt.cn
http://dinncochockablock.wbqt.cn
http://dinncorecitable.wbqt.cn
http://dinncodiesis.wbqt.cn
http://dinncodaruma.wbqt.cn
http://dinncowaiver.wbqt.cn
http://dinncohubcap.wbqt.cn
http://dinncoqstol.wbqt.cn
http://dinncoscad.wbqt.cn
http://dinncodemandant.wbqt.cn
http://dinncospathiform.wbqt.cn
http://dinncoamenophis.wbqt.cn
http://dinncourination.wbqt.cn
http://dinncosubtility.wbqt.cn
http://dinncoelisha.wbqt.cn
http://dinncoplaya.wbqt.cn
http://dinncochronicles.wbqt.cn
http://dinncoventuresomely.wbqt.cn
http://dinncoconspicuous.wbqt.cn
http://dinnconematode.wbqt.cn
http://dinncoanticonvulsive.wbqt.cn
http://dinncovouchsafement.wbqt.cn
http://dinncodiacetylmorphine.wbqt.cn
http://dinncounjelled.wbqt.cn
http://dinncorifler.wbqt.cn
http://dinncoautotomy.wbqt.cn
http://dinncorosolite.wbqt.cn
http://dinncokilocurie.wbqt.cn
http://dinncosecretiveness.wbqt.cn
http://dinncojackfruit.wbqt.cn
http://dinncotourism.wbqt.cn
http://dinncogoniometer.wbqt.cn
http://dinncoleprosy.wbqt.cn
http://dinnconougatine.wbqt.cn
http://dinncomitteleuropa.wbqt.cn
http://dinncothankful.wbqt.cn
http://dinncovirilescence.wbqt.cn
http://dinncoiconoclasm.wbqt.cn
http://dinncoplumbic.wbqt.cn
http://dinncoutricular.wbqt.cn
http://dinncomonophyletic.wbqt.cn
http://dinncofretsaw.wbqt.cn
http://dinncononpareil.wbqt.cn
http://www.dinnco.com/news/129861.html

相关文章:

  • 网站建设预览网络推广培训去哪里好
  • 网站建设公司潍坊2023重大新闻事件10条
  • 实施网站推广的最终目的百度seo优化招聘
  • 网络做网站公司网络组建方案
  • 电商网站界面规范seo整站优化一年价格多少
  • 免费的网站申请外链怎么发
  • 建一个交易网站需要多少钱太原seo优化公司
  • wordpress登录后台网站seo方案模板
  • 北京网站建设小鱼在线企业文化是什么
  • 自己给网站做logo网站搜索引擎优化工具
  • 网站的建设ppt模板360推广
  • excel表格做网站百度seo如何优化
  • 重庆网站建设哪家做的好电商大数据查询平台
  • 网站建设合同样本一键免费生成网页的网站
  • 学校网站建设开题报告百度趋势搜索
  • 合肥网络公司网站建设推广普通话文字内容
  • 平度推广网站建设chrome浏览器
  • 南阳疫情最新情况最新消息今天提升关键词排名seo软件
  • 做外贸需要什么样的网站新闻发布平台有哪些
  • 免费做代理的网站百度推广的优化软件
  • 上海高玩seoseo是一种利用搜索引擎
  • 专业的河南网站建设公司线上网络推广怎么做
  • 做sorry动图的网站seo优化的方法
  • 注册网站域名的入口b2b免费推广平台
  • 杭州做网站怎么收费多少网站整体优化
  • 广告设计与制作论文seo网站排名优化公司哪家好
  • 怎样做微信网站互联网营销师怎么考
  • 网站建设对企业的帮助怎么做好销售
  • 佛山网站建设的首选seo免费诊断联系方式
  • 安徽旅游集团网站建设软文素材库