当前位置:网站首页>剑指 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;
}
}
边栏推荐
- Solon 框架如何方便获取每个请求的响应时间?
- To be continued] [UE4 notes] L4 object editing
- Development error notes
- Quick sort summary
- Zheng Qing 21 ACM is fun. (3) part of the problem solution and summary
- Reader writer model
- Drawing dynamic 3D circle with pure C language
- [es practice] use the native realm security mode on es
- 动漫评分数据分析与可视化 与 IT行业招聘数据分析与可视化
- 一个新的微型ORM开源框架
猜你喜欢
![[speed pointer] 142 circular linked list II](/img/f8/222a360c01d8ef120b61bdd2025044.jpg)
[speed pointer] 142 circular linked list II

GBase数据库助力湾区数字金融发展

Corridor and bridge distribution (csp-s-2021-t1) popular problem solution

Acwing 4300. Two operations

Reverse one-way linked list of interview questions

sync.Mutex源码解读

2022年上半年国家教师资格证考试

lxml.etree.XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8

用STM32点个灯

BUUCTF MISC
随机推荐
Haut OJ 1321: mode problem of choice sister
Applet live + e-commerce, if you want to be a new retail e-commerce, use it!
26、 File system API (device sharing between applications; directory and file API)
[转]:Apache Felix Framework配置属性
Merge sort
软件测试 -- 0 序
Demonstration of using Solon auth authentication framework (simpler authentication framework)
[to be continued] [UE4 notes] L3 import resources and project migration
Bubble sort summary
How can the Solon framework easily obtain the response time of each request?
64 horses, 8 tracks, how many times does it take to find the fastest 4 horses at least
Simple HelloWorld color change
[转]MySQL操作实战(三):表联结
Acwing 4301. Truncated sequence
JVM call not used once in ten years
BUUCTF MISC
Simple modal box
Csp-j-2020-excellent split multiple solutions
使用命令符关闭笔记本自带键盘命令
Yolov5 ajouter un mécanisme d'attention