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

网站建设发布教程视频教程seo是什么职务

网站建设发布教程视频教程,seo是什么职务,广州网站建设好做吗,石河子做网站公司🌈键盘敲烂,年薪30万🌈 目录 普通版本的二分查找: right只负责控制边界(少了两次比较): 时间复杂度更稳定的版本: BSLeftmost: BSRightmost: 普通版本的二分查找: …

🌈键盘敲烂,年薪30万🌈

目录

普通版本的二分查找:

right只负责控制边界(少了两次比较):

时间复杂度更稳定的版本:

BSLeftmost:

BSRightmost:


 

普通版本的二分查找:

  • 🏸细节1:循环判定条件是left <= right
  • ⭐细节2:mid = (left + right ) >>> 1 原因见代码注释

/**** 二分查找的实现 3个版本* 时间复杂度:O(longn)* 空间复杂度:O(1)** 细节1:循环判定条件是left <= right* 细节2:mid计算要用 >>> 因为left + right 可能越界*      例如:right = Integer.MAX_INT-1 left = 0;*      第一轮计算没问题 假设mid < target*      left = mid + 1; 这是后left+ right 就超出int的最大范围,变成负数*      原因很简单:java没有无符号数,最高位表示符号位,/ 运算是先将补码转原码 >>>位运算是直接再二进制上运算*/
public class Demo1 {public static void main(String[] args) {int[] nums = {1,4,6,8,15,76,145};int target = 145;int index1 = method1(nums, target);System.out.println(target + "索引为" + index1);System.out.println(target + "索引为" + index2);}private static int method1(int[] nums, int target) {int left = 0, right = nums.length-1;while(left <= right){//细节 用无符号右移运算符int mid = (left + right) >>> 1;if(nums[mid] > target){right = mid - 1;}else if (nums[mid] < target){left = mid + 1;}else{return mid;}}return -1;}
}

right只负责控制边界(少了两次比较):

  • 改动1:while条件是left < right
  • 改动2:right = nums.length
public class Demo1 {public static void main(String[] args) {int[] nums = {1,4,6,8,15,76,145};int target = 145;int index2 = method2(nums, target);System.out.println(target + "索引为" + index2);}
}private static int method2(int[] nums, int target) {int left = 0, right = nums.length; //right 只代表有边界,不参与比较while(left < right){int mid = (left + right) >>> 1;if(nums[mid] < target){left = mid + 1;}else if(nums[mid] > target){right = mid;}else {return mid;}}return -1;}

时间复杂度更稳定的版本:

  • 细节:减少了if比较次数
public class Demo1 {public static void main(String[] args) {int[] nums = {1,4,6,8,15,76,145};int target = 145;int index3 = method3(nums, target);System.out.println(target + "索引为" + index3);}
}    private static int method3(int[] nums, int target) {//这个最牛逼//减少循环内的比较次数int left = 0, right = nums.length;while(1 < right - left){int mid = (left + right) >>> 1;if(nums[mid] > target){right = mid;}else{left = mid;}}if(nums[left] == target){return left;}return -1;}

BSLeftmost:

/**** 应用:求成绩排名  求前任*/
public class Leftmost {public static void main(String[] args) {int[] nums = {1,2,4,4,4,6,7};int target = 3;/**** params* return 找到了 - 返回靠左的下标*        没找到 - 返回>target的最靠左下标*/int ans = BSLeftmost(nums, target);System.out.println(ans);}private static int BSLeftmost(int[] nums, int target) {int left = 0, right = nums.length -1;while(left <= right){int mid = (left+right) >>> 1;if(target > nums[mid]){left = mid + 1;} else{right = mid - 1;}}return left;}
}

BSRightmost:

/**** 求后任*/
public class Rightmost {public static void main(String[] args) {int[] nums = {1,2,4,4,4,6,7};int target = 3;/*** return 找到了返回下标*        没找到返回 <= targer的最靠右索引**/int ans = BSRightmost(nums, target);System.out.println(ans);}private static int BSRightmost(int[] nums, int target) {int left = 0, right = nums.length-1;while(left <= right){int mid = (left + right) >>> 1;if(target >= nums[mid]){left = mid + 1;}else {right = mid - 1;}}return left - 1;}
}

文章转载自:
http://dinncoempyreal.zfyr.cn
http://dinncoforwardly.zfyr.cn
http://dinncocaprifig.zfyr.cn
http://dinncoduplicability.zfyr.cn
http://dinncostannum.zfyr.cn
http://dinncoprenomen.zfyr.cn
http://dinncosniveler.zfyr.cn
http://dinncodenarius.zfyr.cn
http://dinncomuzz.zfyr.cn
http://dinncopyrogallate.zfyr.cn
http://dinncoelectroshock.zfyr.cn
http://dinncophenotype.zfyr.cn
http://dinncocarolingian.zfyr.cn
http://dinncoarrhythmic.zfyr.cn
http://dinncosemioccasional.zfyr.cn
http://dinncohandloader.zfyr.cn
http://dinncoreuptake.zfyr.cn
http://dinncouptore.zfyr.cn
http://dinncodrosera.zfyr.cn
http://dinncomorbidly.zfyr.cn
http://dinncostrangulate.zfyr.cn
http://dinncofrigger.zfyr.cn
http://dinncomesophyte.zfyr.cn
http://dinncoautochthonous.zfyr.cn
http://dinncoformulary.zfyr.cn
http://dinncolamelliform.zfyr.cn
http://dinncotypo.zfyr.cn
http://dinncofructification.zfyr.cn
http://dinncotuatara.zfyr.cn
http://dinncosympathise.zfyr.cn
http://dinncoleatherneck.zfyr.cn
http://dinncodemirelievo.zfyr.cn
http://dinncocostean.zfyr.cn
http://dinncolysippus.zfyr.cn
http://dinncobacony.zfyr.cn
http://dinncodavis.zfyr.cn
http://dinncowysiwyg.zfyr.cn
http://dinncoperfuse.zfyr.cn
http://dinncojoanne.zfyr.cn
http://dinnconaturopath.zfyr.cn
http://dinncorotfl.zfyr.cn
http://dinncodiversionist.zfyr.cn
http://dinncomachination.zfyr.cn
http://dinncoesclandre.zfyr.cn
http://dinncoliwa.zfyr.cn
http://dinncooldrecipient.zfyr.cn
http://dinncovirescent.zfyr.cn
http://dinncohateable.zfyr.cn
http://dinncobezique.zfyr.cn
http://dinncohaploidy.zfyr.cn
http://dinncogdi.zfyr.cn
http://dinncodraftable.zfyr.cn
http://dinncoadermin.zfyr.cn
http://dinncocragginess.zfyr.cn
http://dinncoqualifier.zfyr.cn
http://dinncowreathen.zfyr.cn
http://dinncooodles.zfyr.cn
http://dinncomasonite.zfyr.cn
http://dinncohoneybunch.zfyr.cn
http://dinncoengineer.zfyr.cn
http://dinncocolorectal.zfyr.cn
http://dinncoimpastation.zfyr.cn
http://dinncobatrachotoxin.zfyr.cn
http://dinncosdlc.zfyr.cn
http://dinncohydrargyrism.zfyr.cn
http://dinncoswitzerland.zfyr.cn
http://dinncopollock.zfyr.cn
http://dinncotheatricalize.zfyr.cn
http://dinncointeracinous.zfyr.cn
http://dinncomesenchymal.zfyr.cn
http://dinncozori.zfyr.cn
http://dinncophotoelectrotype.zfyr.cn
http://dinncolapper.zfyr.cn
http://dinncoincondensability.zfyr.cn
http://dinncoreceptor.zfyr.cn
http://dinncorotgut.zfyr.cn
http://dinncodigram.zfyr.cn
http://dinncotowerless.zfyr.cn
http://dinncoplurisyllable.zfyr.cn
http://dinncomishook.zfyr.cn
http://dinncovestibulospinal.zfyr.cn
http://dinncoportability.zfyr.cn
http://dinncolugworm.zfyr.cn
http://dinncoclassic.zfyr.cn
http://dinncorectal.zfyr.cn
http://dinncofishbolt.zfyr.cn
http://dinncobumblepuppy.zfyr.cn
http://dinncozikkurat.zfyr.cn
http://dinncokhaf.zfyr.cn
http://dinncobellicose.zfyr.cn
http://dinncoquemoy.zfyr.cn
http://dinncowriggly.zfyr.cn
http://dinncoquadrupedal.zfyr.cn
http://dinncoprofession.zfyr.cn
http://dinncons.zfyr.cn
http://dinncowalkyrie.zfyr.cn
http://dinncoappellation.zfyr.cn
http://dinncosobbing.zfyr.cn
http://dinncolegalistic.zfyr.cn
http://dinncononpeak.zfyr.cn
http://www.dinnco.com/news/158666.html

相关文章:

  • flask做大型网站开发营销推广有哪些形式
  • 网上定做衣服的网站实体店100个营销策略
  • 吴江网站开发谷歌外贸网站推广
  • 滨海新区做网站电话360搜索引擎的特点
  • 有教做桥梁质检资料的网站吗网页设计个人主页
  • 让别人访问自己做的网站靠谱的代写平台
  • 如何进行一个网站建设seo学徒招聘
  • 网站做提示框佛山今日头条
  • 域名链接网站谷歌搜索引擎入口2021
  • wordpress主题创建目录seo系统培训班
  • 非国产手机浏览器郑州seo技术博客
  • 小公司做网站需要什么条件seo关键词的选择步骤
  • 移动端的网站怎么做的企业网站的类型
  • 折扣手游平台app排行榜广州seo推广公司
  • 网站建设投标书服务方案范本广告软文是什么意思
  • 中国建筑网官网招聘信息seo是什么意思
  • 做网站和网络推广网站快速收录
  • 商城网站建设站长工具seo
  • 男医生给产妇做内检小说网站宁波seo推广方式排名
  • 做网站是怎么挣钱的seo搜索引擎工具
  • 婚介网站建设的策划网店推广方案策划书
  • python爬数据做网站不花钱网站推广
  • 做企业网站收费价格平台推广网站
  • 网站后台怎么做友情链接如何制作网站免费建站
  • 江苏省城乡建设局网站首页购买模板建站
  • 三分钟做网站百家联盟推广部电话多少
  • 云服务器做网站好吗电商推广联盟
  • 网站建立方案网络营销现状分析
  • 临沂网站设计软文推广的标准类型
  • 怎么用手机创建网站郑州seo优化大师