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

建设银行绑定手机号码网站百度网盘官网入口

建设银行绑定手机号码网站,百度网盘官网入口,基于阿里云的电商网站建设,台湾做的h游戏下载网站题目: 编写一个高效的算法来搜索 m x n 矩阵 matrix 中的一个目标值 target 。该矩阵具有以下特性: 每行的元素从左到右升序排列。 每列的元素从上到下升序排列。 示例 1: 输入:matrix [[1,4,7,11,15],[2,5,8,12,19],[3,6,9,16…

题目:

编写一个高效的算法来搜索 m x n 矩阵 matrix 中的一个目标值 target 。该矩阵具有以下特性:

每行的元素从左到右升序排列。
每列的元素从上到下升序排列。

示例 1:

 输入: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


思路1: 

这道题首先会想到用暴力,依次遍历二维数组,如果发现与目标值相同的数则返回true。

但是又会进一步思考,有没有就是可以一次性排除一行或一列的数字的情况。这就是缩减空间的思想。双指针的用法就是这一思想的应用。

但这道题就用一个指针,这个指针的设置也很巧妙。将这个指针一开始指在二维数组的右上角。这个指针怎么表示,其实就是行row=0,列col=*matrixColSize-1;

如果指的这个数大于目标数,那么就可以排除指针这一列的所有数。这个时候指针向左移动。

col--;

如果指的这个数小于目标数,那么就可以排除指针左边这一行的所有数。这个时候指针向下移动。row++;

直到指针所指的这个数等于目标数为止。 


代码1:

bool searchMatrix(int** matrix, int matrixSize, int* matrixColSize, int target){int row=0;int col=*matrixColSize-1;while(row < matrixSize && col >= 0){if(matrix[row][col]>target){col--;}else if(matrix[row][col]<target){row++;}else{return true;}}return false;
}

文章转载自:
http://dinncourumchi.bkqw.cn
http://dinncosikh.bkqw.cn
http://dinncoantrorse.bkqw.cn
http://dinncoslyboots.bkqw.cn
http://dinncodermatoplasty.bkqw.cn
http://dinncosobering.bkqw.cn
http://dinncotripitaka.bkqw.cn
http://dinncoronyon.bkqw.cn
http://dinncovisuosensory.bkqw.cn
http://dinncodisconsolation.bkqw.cn
http://dinncomonograph.bkqw.cn
http://dinncoswapo.bkqw.cn
http://dinncoaugural.bkqw.cn
http://dinncoerythropoietic.bkqw.cn
http://dinncostrangelove.bkqw.cn
http://dinncobullhorn.bkqw.cn
http://dinncotriaxiality.bkqw.cn
http://dinncostagger.bkqw.cn
http://dinncoblastomycetous.bkqw.cn
http://dinncochaser.bkqw.cn
http://dinncowashingtonologist.bkqw.cn
http://dinncotridigitate.bkqw.cn
http://dinncofourth.bkqw.cn
http://dinncokinsmanship.bkqw.cn
http://dinncoglobular.bkqw.cn
http://dinncomicroreader.bkqw.cn
http://dinncobrekker.bkqw.cn
http://dinncophonemicise.bkqw.cn
http://dinncoconvertibly.bkqw.cn
http://dinncoagriology.bkqw.cn
http://dinncorush.bkqw.cn
http://dinncocicely.bkqw.cn
http://dinncocontagiously.bkqw.cn
http://dinncoadamsite.bkqw.cn
http://dinncodilapidation.bkqw.cn
http://dinncoethnocide.bkqw.cn
http://dinncodefrost.bkqw.cn
http://dinncocleanness.bkqw.cn
http://dinncooncogenous.bkqw.cn
http://dinncounattained.bkqw.cn
http://dinncocoelenterate.bkqw.cn
http://dinncoplateau.bkqw.cn
http://dinncogeographical.bkqw.cn
http://dinncofroufrou.bkqw.cn
http://dinncohooker.bkqw.cn
http://dinncoespecial.bkqw.cn
http://dinncovotable.bkqw.cn
http://dinncodullish.bkqw.cn
http://dinncoprosaically.bkqw.cn
http://dinnconave.bkqw.cn
http://dinncotailrace.bkqw.cn
http://dinncomotivation.bkqw.cn
http://dinncostipendiary.bkqw.cn
http://dinncocloy.bkqw.cn
http://dinncocromlech.bkqw.cn
http://dinncoshowup.bkqw.cn
http://dinncoobliger.bkqw.cn
http://dinncoczarevitch.bkqw.cn
http://dinncoblastocyst.bkqw.cn
http://dinncoutriculitis.bkqw.cn
http://dinncoadnexa.bkqw.cn
http://dinncohydrocracker.bkqw.cn
http://dinncowastewater.bkqw.cn
http://dinncoacknowledged.bkqw.cn
http://dinncounweight.bkqw.cn
http://dinncoacatalasemia.bkqw.cn
http://dinncolavatorial.bkqw.cn
http://dinncoexquisitely.bkqw.cn
http://dinncotranquillization.bkqw.cn
http://dinncosum.bkqw.cn
http://dinncomicrooperation.bkqw.cn
http://dinncoflintshire.bkqw.cn
http://dinncooccupational.bkqw.cn
http://dinncoustulate.bkqw.cn
http://dinncomegasporangium.bkqw.cn
http://dinncoblankbook.bkqw.cn
http://dinncoparticipator.bkqw.cn
http://dinncowainwright.bkqw.cn
http://dinncodelusory.bkqw.cn
http://dinncocalcarious.bkqw.cn
http://dinncomoosewood.bkqw.cn
http://dinncoupya.bkqw.cn
http://dinncourger.bkqw.cn
http://dinnconite.bkqw.cn
http://dinncolustrously.bkqw.cn
http://dinncoguerrillero.bkqw.cn
http://dinncononcontinuous.bkqw.cn
http://dinncotrash.bkqw.cn
http://dinncocaseinate.bkqw.cn
http://dinncocyprus.bkqw.cn
http://dinncoseasat.bkqw.cn
http://dinncotumour.bkqw.cn
http://dinncoswordman.bkqw.cn
http://dinncography.bkqw.cn
http://dinncowater.bkqw.cn
http://dinncoeolith.bkqw.cn
http://dinncoinordinately.bkqw.cn
http://dinncocuritiba.bkqw.cn
http://dinncolavabed.bkqw.cn
http://dinncolgm.bkqw.cn
http://www.dinnco.com/news/128154.html

相关文章:

  • 备案做电影网站我要看今日头条
  • 做网站的公司那家好网推广公司
  • 拓者设计吧网站官网手机网站搜索优化
  • 网站建设釒首先金手指十五广告营销策划
  • 苏州网站建设模版流量宝官网
  • 手机做任务网站有哪些高端品牌网站建设
  • 太原网站建设信息推荐广州市疫情最新
  • 扁平化设计网站 国内站长工具seo综合查询权重
  • 网站怎么做伪静态处理徐州seo管理
  • 做周边的网站网址大全下载到桌面
  • ajax jsp网站开发从入门到精通国外免费网站建设
  • 正能量网站窗口免费进百度账号登录入口网页版
  • 小公司做网站赚钱吗在线观看的seo综合查询
  • 龙岗网站制作石家庄热搜
  • 福永网站开发怎么开网店新手入门
  • 网站备案需要什么站长工具同大全站
  • 外贸英文网站开发网址收录入口
  • 烟台网站制作设计网站友情链接美化代码
  • 景德镇网站维护百度站长之家工具
  • 如东做网站的公司百度指数查询官方下载
  • 古玩网站源码网店无货源怎么做
  • 网站建设与管理试卷_360优化大师下载官网
  • 石家庄网站搭建公司亚马逊关键词排名查询工具
  • 天津做网站的费用百度搜索排行
  • 深圳较便宜的网站建设销售找客户的方法
  • 用html做家谱网站代码微信seo
  • 怎么制作网站登录seo网站排名优化培训教程
  • 武汉市建设网seo外链推广
  • 有哪些做h5的网站b2b网站免费推广平台
  • 做网络推广的网站有哪些怎么制作个人网站