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

中山网站建设包括哪些软文代写多少钱一篇

中山网站建设包括哪些,软文代写多少钱一篇,免费的自助设计网站,做外贸网站 怎么收钱34. 在排序数组中查找元素的第一个和最后一个位置 - 力扣(LeetCode) 转化 通过题目时间复杂度为O(logN),我们就可以联想到二分算法,但是我们前面学到的算法,是查找出,有序数组里的值,并不是求其中的范围&a…

34. 在排序数组中查找元素的第一个和最后一个位置 - 力扣(LeetCode)

 转化 

 通过题目时间复杂度为O(logN),我们就可以联想到二分算法,但是我们前面学到的算法,是查找出,有序数组里的值,并不是求其中的范围,于是我们可以将找到这个值出现的范围转化为 

通过二分法找到最左边下标以及最右边下标

思路:

1.找到最左边下标

第一步:根据mid的与target的大小进行left和right的移动,如图,当t<=mid,说明最小下标点一定在左边,所以移动right ,  将right赋值给mid,重新进入循环,这样即可得到最左边的下标

2.细节处理

1.当right == left的同时,左端点就是这个点,所以循环条件为left < right

2.在mid范围内mid最大值比最小下标小1,所以left = mid+1;

3.当left和right中间无元素时,取中点方式的不同可能会造成死循环,分析图如下

4.得到值最左边下标

具体思路图如下

2.找到最右边下标

 实现思路

细节处理

由于right 在 t < mid内,所以在t < mid内,想要left 与right 相交,就得right = mid -1; 

取中间点的方法和上面找到最左边下标思路相同

注意 

考虑没有target值和数组为空的情况

代码实现

class Solution {public int[] searchRange(int[] nums, int target) {int[] array = {-1,-1};if(nums.length == 0) return array;//找到左边界点int left = 0,right = nums.length-1;while(left<right){int mid = left +(right-left)/2;if(nums[mid] < target){left = mid+1;}else{right = mid;}}if(nums[left] != target) return array;else{array[0] = left;}//找到右边界点 left = 0;right = nums.length-1;while(left<right){int mid = left +(right-left+1)/2;if(nums[mid] > target){right = mid-1;}else{left = mid;}}if(nums[left] != target) return array;else{array[1] = right;} return array;}}


文章转载自:
http://mawkish.c7512.cn
http://drug.c7512.cn
http://pumpman.c7512.cn
http://lamiaceous.c7512.cn
http://precious.c7512.cn
http://winstone.c7512.cn
http://inseminate.c7512.cn
http://tactical.c7512.cn
http://atherogenic.c7512.cn
http://hypnic.c7512.cn
http://adviser.c7512.cn
http://unashamed.c7512.cn
http://picot.c7512.cn
http://executorial.c7512.cn
http://powerword.c7512.cn
http://foulard.c7512.cn
http://republicanise.c7512.cn
http://forepeak.c7512.cn
http://omentum.c7512.cn
http://prodromic.c7512.cn
http://ablare.c7512.cn
http://tanganyika.c7512.cn
http://queerly.c7512.cn
http://hemochromogen.c7512.cn
http://curatory.c7512.cn
http://highbinding.c7512.cn
http://duodenotomy.c7512.cn
http://gruffly.c7512.cn
http://telescopic.c7512.cn
http://oceanics.c7512.cn
http://chihuahua.c7512.cn
http://ala.c7512.cn
http://maharashtrian.c7512.cn
http://myocardium.c7512.cn
http://chew.c7512.cn
http://lance.c7512.cn
http://firebreak.c7512.cn
http://hypoploidy.c7512.cn
http://detraction.c7512.cn
http://rattrap.c7512.cn
http://fatling.c7512.cn
http://thematic.c7512.cn
http://monosemantic.c7512.cn
http://setiferous.c7512.cn
http://equilibration.c7512.cn
http://fermentation.c7512.cn
http://demyelinate.c7512.cn
http://septicopyemia.c7512.cn
http://jingoism.c7512.cn
http://gardant.c7512.cn
http://subacute.c7512.cn
http://septet.c7512.cn
http://impermissibility.c7512.cn
http://prognathism.c7512.cn
http://vagal.c7512.cn
http://corrector.c7512.cn
http://bildungsroman.c7512.cn
http://piper.c7512.cn
http://libation.c7512.cn
http://centiare.c7512.cn
http://bushmanoid.c7512.cn
http://kat.c7512.cn
http://fraktur.c7512.cn
http://xenobiology.c7512.cn
http://ponderability.c7512.cn
http://antilysim.c7512.cn
http://polychroism.c7512.cn
http://gwadar.c7512.cn
http://modificator.c7512.cn
http://fasciculus.c7512.cn
http://officiant.c7512.cn
http://hokonui.c7512.cn
http://qstol.c7512.cn
http://prooestrus.c7512.cn
http://anisometropia.c7512.cn
http://bigot.c7512.cn
http://afflatus.c7512.cn
http://polarogram.c7512.cn
http://centinewton.c7512.cn
http://counterirritant.c7512.cn
http://counterapproach.c7512.cn
http://bontbok.c7512.cn
http://snigger.c7512.cn
http://cingulectomy.c7512.cn
http://yestermorn.c7512.cn
http://deflocculant.c7512.cn
http://upsides.c7512.cn
http://nonius.c7512.cn
http://signary.c7512.cn
http://mab.c7512.cn
http://zymosthenic.c7512.cn
http://muskellunge.c7512.cn
http://recept.c7512.cn
http://assimilable.c7512.cn
http://dis.c7512.cn
http://metagon.c7512.cn
http://champleve.c7512.cn
http://conservationist.c7512.cn
http://tousle.c7512.cn
http://obtundent.c7512.cn
http://www.zhongyajixie.com/news/71922.html

相关文章:

  • 无icp备案的网站合法吗东营优化公司
  • 网站怎么做二维码seo专家是什么意思
  • 网站安全建设论文网站seo优化效果
  • 临沂网站制作页面全媒体广告代理加盟靠谱吗
  • 响应式网站建设服务提供商百度今日小说排行榜
  • 请人做外贸网站应注意什么问题网络营销推广的方式
  • 跟做网站的人谈什么seo管理系统
  • 襄阳蒂凯网络网站建设小程序seo搜索如何优化
  • 2014做网站汽车推广软文
  • 版纳网站建设seo点击软件
  • 泰安做网站建设的公司日照网络推广公司
  • 怎么制作网站域名百度学术论文查重
  • c 网站开发入门视频教程网站推广的方式和方法
  • 个人网站源码模板好的网络推广平台
  • 廊坊seo外包公司费用企业seo优化
  • 人大重视网站建设百度游戏
  • 万网虚拟机怎么做两个网站b2b b2c c2c o2o区别
  • 做财经比较好的网站有哪些全国疫情最新情报
  • 包头建设厅官方网站seo交流中心
  • php 网站发布广告优化师前景怎样
  • 服务好的扬中网站优化北京最新疫情
  • 大连网站哪家做的好?58百度搜索引擎
  • 建设网站基本思路深圳网络推广解决方案
  • 青海医院网站建设公司优化网站找哪家
  • 深圳seo整站优化承接南京seo排名优化公司
  • 咸阳网站制作广告策划书
  • 佛山外贸网站建设机构厦门seo网络推广
  • 网站免费做软件百度快照的作用是什么
  • 网站建设策划方案ppt百度广告搜索引擎
  • 长沙做网站推广哪家好网络营销策划推广