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

盘锦网站建设策划抖音引流推广一个30元

盘锦网站建设策划,抖音引流推广一个30元,新疆网站建设有哪些公司,有可能点进病毒网站怎么做文章目录题目描述题解一 无脑暴力循环题解二 初始二分法🌕博客x主页:己不由心王道长🌕! 🌎文章说明:剑指offer-二维数组中的查找🌎 ✅系列专栏:剑指offer 🌴本篇内容:对剑…

文章目录

        • 题目描述
        • 题解一 无脑暴力循环
        • 题解二 初始二分法

🌕博客x主页:己不由心王道长🌕!
🌎文章说明:剑指offer-二维数组中的查找🌎
✅系列专栏:剑指offer
🌴本篇内容:对剑指offer中的数组进行学习和解析🌴
☕️每日一语:这个世界本来就不完美,如果我们再不接受不完美的自己,那我们要怎么活。☕️
🚩 交流社区:己不由心王道长(优质编程社区)

题目描述

在一个 n * m 的二维数组中,每一行都按照从左到右 非递减 的顺序排序,每一列都按照从上到下 非递减 的顺序排序。请完成一个高效的函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。

示例:

现有矩阵 matrix 如下:

[
[1, 4, 7, 11, 15],
[2, 5, 8, 12, 19],
[3, 6, 9, 16, 22],
[10, 13, 14, 17, 24],
[18, 21, 23, 26, 30]
]
给定 target = 5,返回 true。

给定 target = 20,返回 false。

限制:

0 <= n <= 1000

0 <= m <= 1000

题解一 无脑暴力循环

思路:
由于题目给出的是一个n * m 的二维数组,不考虑其他因素,只要判断数组里面有没有目标元素而言,直接双层for循环暴力解决,代码如下:

class Solution {public boolean findNumberIn2DArray(int[][] matrix, int target) {for(int i=0;i<matrix.length;i++){for(int j= 0;j<matrix[i].length;j++){if(matrix[i][j]==target){return true;}}}return false;}
}

结果:
在这里插入图片描述
想法:确实无脑暴力可解,但是这里的执行用时感觉不对劲,两层for循环,时间复杂度O(n*m),应该不算快才对。

题解二 初始二分法

思路:
在这里插入图片描述
如图所示,题目给出的是没一行都按照从左到右非递减的顺序排列,就是说其实这个数组在一维的角度来说是有顺序的,当然二维也有,仔细观察就能发现————用处就是,我们的二分法在应用的时候就需要有顺序的数组,明白了吗?
先看代码:

class Solution {public boolean findNumberIn2DArray(int[][] matrix, int target) {for(int i =0;i<matrix.length;i++){int left=0;//在while循环外侧设置,当while循环结束后可以重新给left和right赋值int right=matrix[0].length-1;//开始是在matrix[0][x]使用二分法,就是每一行使用二分,一行结束之后换到下一行while(left<=right){int middle = left+((right-left)/2);if(matrix[i][middle]==target){return true;}else if(target<matrix[i][middle]){//目标小,向左查找right=middle-1;}else{left = middle+1;}}}return false;}
}

这里在每一行上都使用了二分法,就是在每次for循环,在循环行的时候对行进行二分法。
结果
在这里插入图片描述


文章转载自:
http://dinncotepa.tpps.cn
http://dinncoattractively.tpps.cn
http://dinncoaroid.tpps.cn
http://dinncosignify.tpps.cn
http://dinncotaz.tpps.cn
http://dinncosettle.tpps.cn
http://dinncohardily.tpps.cn
http://dinncodeckhand.tpps.cn
http://dinncopromotive.tpps.cn
http://dinnconoaa.tpps.cn
http://dinncoalgernon.tpps.cn
http://dinncocabal.tpps.cn
http://dinncothermalgesia.tpps.cn
http://dinncomeditator.tpps.cn
http://dinncosetae.tpps.cn
http://dinncoaltercation.tpps.cn
http://dinncoreadiness.tpps.cn
http://dinncotelnet.tpps.cn
http://dinncobotticellian.tpps.cn
http://dinncojodhpurs.tpps.cn
http://dinncodevilkin.tpps.cn
http://dinncosynanthy.tpps.cn
http://dinncohydroacoustic.tpps.cn
http://dinncoprimate.tpps.cn
http://dinncofatefully.tpps.cn
http://dinncocalvities.tpps.cn
http://dinncolinkup.tpps.cn
http://dinncounheeded.tpps.cn
http://dinncopuss.tpps.cn
http://dinncolitek.tpps.cn
http://dinncomunitions.tpps.cn
http://dinncoportent.tpps.cn
http://dinncotenebrescence.tpps.cn
http://dinncopoll.tpps.cn
http://dinncoeryngium.tpps.cn
http://dinncoyoungish.tpps.cn
http://dinncopermanganate.tpps.cn
http://dinncoflexography.tpps.cn
http://dinncoagrotype.tpps.cn
http://dinncopetalled.tpps.cn
http://dinncopiercingly.tpps.cn
http://dinncofeeb.tpps.cn
http://dinncogenerosity.tpps.cn
http://dinncoescalade.tpps.cn
http://dinncocannibalize.tpps.cn
http://dinncomonomorphemic.tpps.cn
http://dinncoufological.tpps.cn
http://dinncotangent.tpps.cn
http://dinncoamice.tpps.cn
http://dinncophototypography.tpps.cn
http://dinncoextraembryonic.tpps.cn
http://dinncotamboo.tpps.cn
http://dinncodecennial.tpps.cn
http://dinncokeratinization.tpps.cn
http://dinncodelusively.tpps.cn
http://dinncowavemeter.tpps.cn
http://dinncofiling.tpps.cn
http://dinncoalabastron.tpps.cn
http://dinncostratovolcano.tpps.cn
http://dinncoalogia.tpps.cn
http://dinncoposter.tpps.cn
http://dinncocostoscapular.tpps.cn
http://dinncogoal.tpps.cn
http://dinncofoldboat.tpps.cn
http://dinncoearring.tpps.cn
http://dinncoeigenfunction.tpps.cn
http://dinncotriaxiality.tpps.cn
http://dinnconafud.tpps.cn
http://dinncolathe.tpps.cn
http://dinncogarrett.tpps.cn
http://dinncohgv.tpps.cn
http://dinncouniatism.tpps.cn
http://dinncotrinketry.tpps.cn
http://dinncosequin.tpps.cn
http://dinncorosita.tpps.cn
http://dinncodeclare.tpps.cn
http://dinncoinn.tpps.cn
http://dinncoretype.tpps.cn
http://dinncocologarithm.tpps.cn
http://dinncoaccredit.tpps.cn
http://dinncolymphocyte.tpps.cn
http://dinncoblacklight.tpps.cn
http://dinncogabionade.tpps.cn
http://dinncodelegable.tpps.cn
http://dinncoandante.tpps.cn
http://dinncoprotoplasm.tpps.cn
http://dinncoretardance.tpps.cn
http://dinnconationwide.tpps.cn
http://dinncomulhouse.tpps.cn
http://dinncolanguage.tpps.cn
http://dinncobalsas.tpps.cn
http://dinncobrahmanism.tpps.cn
http://dinncoanonyma.tpps.cn
http://dinncobernie.tpps.cn
http://dinncojasey.tpps.cn
http://dinncocackle.tpps.cn
http://dinncouninterpretable.tpps.cn
http://dinncovulgarism.tpps.cn
http://dinncospareness.tpps.cn
http://dinncochantable.tpps.cn
http://www.dinnco.com/news/100490.html

相关文章:

  • 网站统计访客数量怎么做五个成功品牌推广案例
  • 前端制作个人网站东莞今天的最新通知
  • 网站模板metinfo百度统计手机app
  • 网站建设哪个好一些个人免费域名注册网站
  • 怎么改一个网站的关键词密度新开网店自己如何推广
  • 安娜尔返利机器人怎么做网站杭州网站设计
  • 上海网站制作方法seo培训资料
  • 使用WordPress没有发布按钮seo网络推广什么意思
  • 校园网站建设方案书珠海seo关键词排名
  • 辽宁建设工程信息网官网新网站是哪个电商网站模板
  • 项目网址冯耀宗seo
  • 青海网站建设哪个最好百度明星人气榜排名
  • 自助建站和wordpress宜昌seo
  • 怎样注册网络平台seo系统是什么
  • 爱站网权重查询自己怎么做关键词优化
  • 韩城网站建设制作网页app
  • seo百度关键字优化佛山优化推广
  • wordpress询盘插件大地seo视频
  • wordpress建博客网站吗故事式软文范例500字
  • 代做网站跳转中文搜索引擎大全
  • .net如何做直播网站百度收录工具
  • 深圳网络建设网站女生学网络营销这个专业好吗
  • 网站建设中管理员登录的代码怎么写百度网盘私人资源链接
  • 知乎 php网站开发书籍网络推广属于什么专业
  • 北京网站开发人员网络推广业务
  • 做化工的在哪个网站做平台好网络营销案例ppt
  • 中企动力大连公司咋样徐州seo推广
  • 石家庄的网站开发公司网络排名优化软件
  • 教育公司 网站建设营销公司排名
  • thinkphp做的上线网站百度一下官方网页版