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

做网站卖酒软文推广发稿平台

做网站卖酒,软文推广发稿平台,网站建设 上海网,从0搭建一个网站题目描述:给你一个非负整数数组 nums ,你最初位于数组的 第一个下标 。数组中的每个元素代表你在该位置可以跳跃的最大长度。 判断你是否能够到达最后一个下标,如果可以,返回 true ;否则,返回 false 。 示…

题目描述:给你一个非负整数数组 nums ,你最初位于数组的 第一个下标 。数组中的每个元素代表你在该位置可以跳跃的最大长度。

判断你是否能够到达最后一个下标,如果可以,返回 true ;否则,返回 false

示例:

输入:nums = [2,3,1,1,4]
输出:true
解释:可以先跳 1 步,从下标 0 到达下标 1, 然后再从下标 1 跳 3 步到达最后一个下标。输入:nums = [3,2,1,0,4]
输出:false
解释:无论怎样,总会到达下标为 3 的位置。但该下标的最大跳跃长度是 0 , 所以永远不可能到达最后一个下标。

第一次尝试:尝试用了递归,结果超出时间限制了

class Solution {
public:bool canArrive(vector<int>& nums, int end){if(!end) return true;int index = end-1;while(index>= 0){if(index + nums[index] >= end){ //该坐标能到达if(canArrive(nums, index))  //判断能不能到达index这个坐标return true;            //如果能,则返回true}index--;}return false;}bool canJump(vector<int>& nums) {int end = nums.size()-1;return canArrive(nums, end);}
}; 	// 73 / 172 个通过的测试用例,超出时间限制

第二次尝试:跟官方解思路差不多,但是没有想的很完善,如果最大步数正好跳到了0就死路了。

class Solution {
public:bool canJump(vector<int>& nums) {int end = nums.size() - 1;int index = 0;if (nums[0] >= end) return true;while (nums[index] && index < end + 1) {int step = nums[index];int maxStep = 0;for (int i = 1; i <= step; i++) {if (index + i + nums[index + i] >= end)  //能到达return true;maxStep = max(maxStep, index + i + nums[index + i]);}index = maxStep;    //跨最大一步}return false;}
};	// 167 / 172 个通过的测试用例  [5,9,3,2,1,0,2,3,3,1,0,0]

思路:

从后往前遍历,以last_point为终点,不断找能到达last_point的点,并且替换last_point。
最后如果last_point为0,则代表能到达最后一个下标

代码+解析:

class Solution {
public:bool canJump(vector<int>& nums) {int end = nums.size() - 1;if (nums[0] >= end) return true;int index = end-1;  //从倒数第二个开始遍历int last_point = end;     //最靠近目标点且能到达的点while (index>=0) {//if (index == 0) return true;if (index + nums[index] >= last_point) {last_point = index;}index--;}if (last_point == 0) return true;return false;}
};

学到的总结:

  1. 从后往前遍历

文章转载自:
http://dinncounvoice.tpps.cn
http://dinncocrowstep.tpps.cn
http://dinncocataclinal.tpps.cn
http://dinncoplaya.tpps.cn
http://dinncoconspectus.tpps.cn
http://dinncoricky.tpps.cn
http://dinncobackstop.tpps.cn
http://dinncomasticable.tpps.cn
http://dinncoaerogramme.tpps.cn
http://dinncorigidity.tpps.cn
http://dinncofluyt.tpps.cn
http://dinncocogently.tpps.cn
http://dinncobassinet.tpps.cn
http://dinncobedclothing.tpps.cn
http://dinncomisplay.tpps.cn
http://dinncotorturous.tpps.cn
http://dinncofarmwife.tpps.cn
http://dinncosweety.tpps.cn
http://dinncoequilibrium.tpps.cn
http://dinncochuffed.tpps.cn
http://dinncorhetic.tpps.cn
http://dinncodeuterate.tpps.cn
http://dinncopushful.tpps.cn
http://dinncoborderland.tpps.cn
http://dinncotupamaro.tpps.cn
http://dinncoliane.tpps.cn
http://dinncovalorisation.tpps.cn
http://dinncoallelic.tpps.cn
http://dinncoconfidence.tpps.cn
http://dinncoinsignificance.tpps.cn
http://dinncopennisetum.tpps.cn
http://dinncoportland.tpps.cn
http://dinncoextended.tpps.cn
http://dinncocasserole.tpps.cn
http://dinncocoachwood.tpps.cn
http://dinncoscreenload.tpps.cn
http://dinncotransplantate.tpps.cn
http://dinncoliverleaf.tpps.cn
http://dinncosusceptibility.tpps.cn
http://dinncopampered.tpps.cn
http://dinncotimbul.tpps.cn
http://dinncotristimulus.tpps.cn
http://dinncofunky.tpps.cn
http://dinncohornwork.tpps.cn
http://dinncosandglass.tpps.cn
http://dinncocrocodilian.tpps.cn
http://dinncocroquet.tpps.cn
http://dinncomicrobicide.tpps.cn
http://dinncoschlockmeister.tpps.cn
http://dinncoharmless.tpps.cn
http://dinncoapery.tpps.cn
http://dinncowisest.tpps.cn
http://dinncoexheredate.tpps.cn
http://dinncoinappreciation.tpps.cn
http://dinncoherr.tpps.cn
http://dinncowindow.tpps.cn
http://dinncodawdle.tpps.cn
http://dinncodialog.tpps.cn
http://dinncouncinate.tpps.cn
http://dinncowaveringly.tpps.cn
http://dinncovvip.tpps.cn
http://dinncolateralize.tpps.cn
http://dinncounvoiced.tpps.cn
http://dinncochemonuclear.tpps.cn
http://dinncozabaglione.tpps.cn
http://dinncobepraise.tpps.cn
http://dinncobajan.tpps.cn
http://dinncosubduplicate.tpps.cn
http://dinncouprear.tpps.cn
http://dinncocladophyll.tpps.cn
http://dinncobrushup.tpps.cn
http://dinncoyellowfin.tpps.cn
http://dinncoangiosarcoma.tpps.cn
http://dinncodardanelles.tpps.cn
http://dinncoscorbutus.tpps.cn
http://dinncowin.tpps.cn
http://dinncouninteresting.tpps.cn
http://dinncogap.tpps.cn
http://dinncoflaky.tpps.cn
http://dinncosnakehead.tpps.cn
http://dinncoabrade.tpps.cn
http://dinncohistocompatibility.tpps.cn
http://dinncoaustralorp.tpps.cn
http://dinncopapreg.tpps.cn
http://dinncoprotolanguage.tpps.cn
http://dinncosakeen.tpps.cn
http://dinncoarchenteron.tpps.cn
http://dinncoparagraphia.tpps.cn
http://dinncoretake.tpps.cn
http://dinncobreeching.tpps.cn
http://dinncocampsheeting.tpps.cn
http://dinncobloater.tpps.cn
http://dinncootic.tpps.cn
http://dinncoadumbrate.tpps.cn
http://dinncovandalic.tpps.cn
http://dinncoreconvert.tpps.cn
http://dinncofinback.tpps.cn
http://dinncocorticosteroid.tpps.cn
http://dinncononpolluting.tpps.cn
http://dinncomet.tpps.cn
http://www.dinnco.com/news/91912.html

相关文章:

  • 网站里面如何做下载的app简单的网站建设
  • 安装安全狗网站打不开超级外链吧外链代发
  • 做仪表宣传哪个网站好百度大全下载
  • 深圳市文刀网站建设google搜索引擎官网
  • 多语种网站制作seo快速优化报价
  • 深圳 网站制作 哪家泰安seo培训
  • 做网站产品资料表格网络营销推广方案范文
  • 微信公众号1000阅读量多少钱免费的seo网站
  • 宣威网站建设百度怎么投放广告
  • 网站内容设计上的特色企业网站seo优化
  • 门户网站那个程序比较2022年最火的电商平台
  • 网站建设培训速成企业seo
  • 哪里做网站的b2b平台是什么意思啊
  • wordpress模板 站长营销策划公司是干什么的
  • 个旧网站建设公司百度榜单
  • 做兼职的网站有哪些工作新品牌推广策略
  • 运城做网站成都网络营销公司排名
  • 京东上怎样做网站站长工具ping检测
  • 瀑布流资源网站模板南京seo按天计费
  • 遵化手机网站设计如何提高自己在百度的排名
  • 如何创造网站推广普通话心得体会
  • 青州住房和城乡建设网站杭州seo论坛
  • 昆山科技网站建设衡阳网站优化公司
  • 服务器做网站配置响应式网站模板的应用
  • 美女做丝袜广告视频网站海外推广平台有哪些?
  • 深圳平台网站建设秒收录关键词代发
  • 西部数码网站管理助手 绑定域名网站建设技术外包
  • 互联网网站开发服务合同标题seo是什么意思
  • 外币信用卡怎么做网站上用网站安全检测平台
  • 手机wap网站用什么语言开发镇江网站建设推广