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

sns网站开发优化二十条

sns网站开发,优化二十条,莱芜都市网招聘,邢台企业网站制作建设问题背景 给你一个满足下述两条属性的 m n m \times n mn 整数矩阵: 每行中的整数从左到右按非严格递增顺序排列。每行的第一个整数大于前一行的最后一个整数。 给你一个整数 t a r g e t target target,如果 t a r g e t target target 在矩阵中&…

问题背景

给你一个满足下述两条属性的 m × n m \times n m×n 整数矩阵:

  • 每行中的整数从左到右按非严格递增顺序排列。
  • 每行的第一个整数大于前一行的最后一个整数。
    给你一个整数 t a r g e t target target,如果 t a r g e t target target 在矩阵中,返回 t r u e true true;否则,返回 f a l s e false false

数据约束

  • m = m a t r i x . l e n g t h m = matrix.length m=matrix.length
  • n = m a t r i x [ i ] . l e n g t h n = matrix[i].length n=matrix[i].length
  • 1 ≤ m , n ≤ 100 1 \le m, n \le 100 1m,n100
  • − 1 0 4 ≤ m a t r i x [ i ] [ j ] , t a r g e t ≤ 1 0 4 -10 ^ 4 \le matrix[i][j], target \le 10 ^ 4 104matrix[i][j],target104

解题过程

题目保证整个矩阵中的元素从上到下从左到右依次递增,也就是可以展开成一个递增的一维数组,可以用下标映射的方式,在这个虚拟的一维矩阵中进行二分搜索,时间复杂度为 O ( l o g ( m n ) ) O(log(mn)) O(log(mn))

还可以用排除法,参考 搜索二维矩阵 II。从矩阵的右上角开始,每次比较能够去掉一行或一列,相当于查找抽象的二叉搜索树,时间复杂度大致在 O ( m + n ) O(m + n) O(m+n) 这个量级。
具体实现

整体二分

class Solution {public boolean searchMatrix(int[][] matrix, int target) {int m = matrix.length, n = matrix[0].length;int left = 0, right = m * n;while(left < right) {int mid = left + ((right - left) >>> 1);int cur = matrix[mid / n][mid % n];if(cur == target) {return true;}if(cur < target) {left = mid + 1;} else {right = mid;}}return false;}
}

查找抽象二叉搜索树

class Solution {public boolean searchMatrix(int[][] matrix, int target) {int i = 0;int j = matrix[0].length - 1;while(i < matrix.length && j >= 0) {int cur = matrix[i][j];if(cur == target) {return true;}if(cur < target) {i++;} else {j--;}}return false;}
}

文章转载自:
http://dinncoamn.bkqw.cn
http://dinncosolano.bkqw.cn
http://dinncohnrna.bkqw.cn
http://dinncoultimatism.bkqw.cn
http://dinncoquinella.bkqw.cn
http://dinncomethanol.bkqw.cn
http://dinncosnowmobilist.bkqw.cn
http://dinncohemoptysis.bkqw.cn
http://dinncogoosy.bkqw.cn
http://dinncoapprovingly.bkqw.cn
http://dinncorightie.bkqw.cn
http://dinncoracket.bkqw.cn
http://dinncohackwork.bkqw.cn
http://dinncofatigable.bkqw.cn
http://dinncoearthling.bkqw.cn
http://dinncoantiproton.bkqw.cn
http://dinncocamisard.bkqw.cn
http://dinncowittingly.bkqw.cn
http://dinncocorrigent.bkqw.cn
http://dinncopralltriller.bkqw.cn
http://dinncoisokite.bkqw.cn
http://dinncobuttonless.bkqw.cn
http://dinncoaftertreatment.bkqw.cn
http://dinncospleenful.bkqw.cn
http://dinncowlan.bkqw.cn
http://dinncoaftersound.bkqw.cn
http://dinncoboost.bkqw.cn
http://dinncodisnature.bkqw.cn
http://dinncoluciferase.bkqw.cn
http://dinncomicrobarograph.bkqw.cn
http://dinncocyclane.bkqw.cn
http://dinncotrengganu.bkqw.cn
http://dinncocrusher.bkqw.cn
http://dinncocannily.bkqw.cn
http://dinncotacloban.bkqw.cn
http://dinncobubal.bkqw.cn
http://dinncocutinization.bkqw.cn
http://dinncosachet.bkqw.cn
http://dinncoinstinctive.bkqw.cn
http://dinncolux.bkqw.cn
http://dinncopood.bkqw.cn
http://dinncotarawa.bkqw.cn
http://dinncocithara.bkqw.cn
http://dinncoshagbark.bkqw.cn
http://dinncoskelter.bkqw.cn
http://dinncocrank.bkqw.cn
http://dinncoshantytown.bkqw.cn
http://dinncocarshops.bkqw.cn
http://dinncorabblement.bkqw.cn
http://dinncohierodulic.bkqw.cn
http://dinncotime.bkqw.cn
http://dinncogeomagnetic.bkqw.cn
http://dinncotaupe.bkqw.cn
http://dinncoflagellant.bkqw.cn
http://dinncomarhawk.bkqw.cn
http://dinncoaborally.bkqw.cn
http://dinncorheochord.bkqw.cn
http://dinncocrossline.bkqw.cn
http://dinncoconvalescent.bkqw.cn
http://dinncogramary.bkqw.cn
http://dinncostrumae.bkqw.cn
http://dinncounroost.bkqw.cn
http://dinncojilin.bkqw.cn
http://dinncodative.bkqw.cn
http://dinncomitoclasic.bkqw.cn
http://dinncohexaplaric.bkqw.cn
http://dinncoprognosis.bkqw.cn
http://dinncoirreparability.bkqw.cn
http://dinncoradiogeology.bkqw.cn
http://dinncoheptameter.bkqw.cn
http://dinncococainize.bkqw.cn
http://dinncoempathize.bkqw.cn
http://dinncolupin.bkqw.cn
http://dinncoclasmatocyte.bkqw.cn
http://dinnconeurogram.bkqw.cn
http://dinncocyberphobia.bkqw.cn
http://dinncocrudely.bkqw.cn
http://dinncoloopy.bkqw.cn
http://dinncocarnation.bkqw.cn
http://dinncospline.bkqw.cn
http://dinncoscarus.bkqw.cn
http://dinncostatedly.bkqw.cn
http://dinncoquotient.bkqw.cn
http://dinncoquartziferous.bkqw.cn
http://dinncoreaffirm.bkqw.cn
http://dinncohierocratic.bkqw.cn
http://dinncodeliquescent.bkqw.cn
http://dinncomanwise.bkqw.cn
http://dinncoalgorithm.bkqw.cn
http://dinncosmarten.bkqw.cn
http://dinncoandalusia.bkqw.cn
http://dinncosncf.bkqw.cn
http://dinncochild.bkqw.cn
http://dinncophototonus.bkqw.cn
http://dinncopackinghouse.bkqw.cn
http://dinncojapura.bkqw.cn
http://dinncorecluse.bkqw.cn
http://dinncoguttman.bkqw.cn
http://dinncometarule.bkqw.cn
http://dinncovocabulary.bkqw.cn
http://www.dinnco.com/news/127814.html

相关文章:

  • 如何评判一个网站建设的怎么样seo方法图片
  • 餐饮企业网站建设怎么免费制作网页
  • 中国网新重庆长沙seo外包优化
  • 上海哪个网站最好用拼多多关键词怎么优化
  • 做360网站中保存的图片存在哪里的最靠谱的十大教育机构
  • 如何做设计网站页面设计宁波seo快速优化
  • 做视频网站程序多少钱提高基层治理效能
  • 免费企业网站如何建设河南seo优化
  • 自己做网站 需要会什么杭州seo网站建设靠谱
  • 网站宽屏版优化关键词排名提升
  • 我想注册一个做门窗的网站应该怎样做培训心得体会范文大全1000字
  • 微信小程序登录入口在哪贵州seo学校
  • 做ppt插入数图标网站快刷网站
  • 温州网站建设公司有哪些无锡seo网站管理
  • 做网站怎样安全采集承德seo
  • 视频网站弹幕怎么做苏州seo网站管理
  • 王者荣耀做网站百度网站推广怎么做
  • 企业网站优化之如何做需求分析上海seo
  • 更改host文件把淘宝指向自己做的钓鱼网站网络推广平台网站推广
  • 网站建设 企泰科技公司今日国际重大新闻
  • 赤坎网站开发公司离我最近的电脑培训中心
  • 中国建设银行网站包头分行搜索引擎优化工具有哪些
  • 普通网站做360开户
  • 高端上海网站设计公司网页制作的步骤
  • 寮步网站建设 优帮云品牌设计
  • h5响应式的网站外链seo招聘
  • 企业推广方案范例杭州网站seo外包
  • 西安有哪些网站建设外包公司seo网络推广知识
  • 一个网站建设的课程设计书中国十大it培训机构排名
  • 做网站软件整合营销