当前位置:网站首页>Sword finger offer 04 Search in two-dimensional array
Sword finger offer 04 Search in two-dimensional array
2022-07-05 05:28:00 【ThE wAlkIng D】
Title Description

Problem analysis
- Notice how the two-dimensional array is incremented , Locate the lower left corner as the starting point and start traversal according to the incremental method
- Be careful .length( For any array , Take out its capacity ) and .length()( For Strings ) The difference between
Code instance
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;
}
}
边栏推荐
- YOLOv5添加注意力機制
- 剑指 Offer 05. 替换空格
- [allocation problem] 455 Distribute cookies
- Support multi-mode polymorphic gbase 8C database continuous innovation and heavy upgrade
- Quick sort summary
- Zzulioj 1673: b: clever characters???
- room数据库的使用
- Drawing dynamic 3D circle with pure C language
- [轉]: OSGI規範 深入淺出
- Use of room database
猜你喜欢

剑指 Offer 05. 替换空格

lxml. etree. XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8
![To be continued] [UE4 notes] L4 object editing](/img/0f/cfe788f07423222f9eed90f4cece7d.jpg)
To be continued] [UE4 notes] L4 object editing

Hang wait lock vs spin lock (where both are used)

Yolov5 ajouter un mécanisme d'attention

一个新的微型ORM开源框架

Support multi-mode polymorphic gbase 8C database continuous innovation and heavy upgrade

剑指 Offer 09. 用两个栈实现队列

远程升级怕截胡?详解FOTA安全升级

利用HashMap实现简单缓存
随机推荐
Development error notes
Solon 框架如何方便获取每个请求的响应时间?
National teacher qualification examination in the first half of 2022
Haut OJ 1245: large factorial of CDs --- high precision factorial
挂起等待锁 vs 自旋锁(两者的使用场合)
第六章 数据流建模—课后习题
[转]MySQL操作实战(三):表联结
A preliminary study of sdei - see the essence through transactions
[转]MySQL操作实战(一):关键字 & 函数
Csp-j-2020-excellent split multiple solutions
Es module and commonjs learning notes
SAP method of modifying system table data
使用Electron开发桌面应用
Reverse one-way linked list of interview questions
Programmers' experience of delivering takeout
Gbase database helps the development of digital finance in the Bay Area
To the distance we have been looking for -- film review of "flying house journey"
Zheng Qing 21 ACM is fun. (3) part of the problem solution and summary
[trans]: spécification osgi
每日一题-无重复字符的最长子串