当前位置:网站首页>剑指 Offer 04. 二维数组中的查找
剑指 Offer 04. 二维数组中的查找
2022-07-05 05:26:00 【ThE wAlkIng D】
题目描述
问题解析
- 注意二维数组的递增方式,根据递增方式定位左下角作为起始点开始遍历
- 注意.length(针对任意数组,取出它的容量)和.length()(针对字符串)之间的区别
代码实例
class Solution {
public boolean findNumberIn2DArray(int[][] array, int target) {
int row = array.length - 1;
int col = 0;
while(row >= 0 && (col<array[0].length){
if(array[row][col] > target){
row--;
}
else if(array[row][col] < target){
col++;
}
else{
return true;
}
}
return false;
}
}
边栏推荐
- National teacher qualification examination in the first half of 2022
- Reader writer model
- [speed pointer] 142 circular linked list II
- Solon Logging 插件的添加器级别控制和日志器的级别控制
- Count sort
- A new micro ORM open source framework
- Solon 框架如何方便获取每个请求的响应时间?
- Applet Live + e - commerce, si vous voulez être un nouveau e - commerce de détail, utilisez - le!
- Web APIs DOM节点
- Animation scoring data analysis and visualization and it industry recruitment data analysis and visualization
猜你喜欢
[speed pointer] 142 circular linked list II
利用HashMap实现简单缓存
C language Essay 1
Magnifying glass effect
2022年上半年国家教师资格证考试
[to be continued] [UE4 notes] L1 create and configure items
National teacher qualification examination in the first half of 2022
远程升级怕截胡?详解FOTA安全升级
Simple modal box
[paper notes] multi goal reinforcement learning: challenging robotics environments and request for research
随机推荐
[paper notes] multi goal reinforcement learning: challenging robotics environments and request for research
Zheng Qing 21 ACM is fun. (3) part of the problem solution and summary
Embedded database development programming (V) -- DQL
Applet live + e-commerce, if you want to be a new retail e-commerce, use it!
Acwing 4301. Truncated sequence
YOLOv5-Shufflenetv2
TF-A中的工具介绍
[allocation problem] 455 Distribute cookies
Download xftp7 and xshell7 (official website)
Remote upgrade afraid of cutting beard? Explain FOTA safety upgrade in detail
Embedded database development programming (zero)
BUUCTF MISC
Reverse one-way linked list of interview questions
使用命令符关闭笔记本自带键盘命令
What is the agile proportion of PMP Exam? Dispel doubts
Haut OJ 2021 freshmen week II reflection summary
On-off and on-off of quality system construction
[depth first search] 695 Maximum area of the island
服务熔断 Hystrix
To the distance we have been looking for -- film review of "flying house journey"