当前位置:网站首页>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;
}
}
边栏推荐
- A new micro ORM open source framework
- Romance of programmers on Valentine's Day
- 挂起等待锁 vs 自旋锁(两者的使用场合)
- [speed pointer] 142 circular linked list II
- Detailed explanation of expression (csp-j 2021 expr) topic
- Quick sort summary
- Heap sort summary
- 剑指 Offer 06.从头到尾打印链表
- [allocation problem] 455 Distribute cookies
- Count sort
猜你喜欢
随机推荐
Yolov5 adds attention mechanism
[to be continued] [UE4 notes] L3 import resources and project migration
[trans]: spécification osgi
[to be continued] [depth first search] 547 Number of provinces
Zzulioj 1673: b: clever characters???
Programmers' experience of delivering takeout
A misunderstanding about the console window
[binary search] 34 Find the first and last positions of elements in a sorted array
lxml. etree. XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8
26、 File system API (device sharing between applications; directory and file API)
Chapter 6 data flow modeling - after class exercises
Under the national teacher qualification certificate in the first half of 2022
[to be continued] [UE4 notes] L2 interface introduction
Support multi-mode polymorphic gbase 8C database continuous innovation and heavy upgrade
A new micro ORM open source framework
Developing desktop applications with electron
剑指 Offer 04. 二维数组中的查找
Haut OJ 1243: simple mathematical problems
Es module and commonjs learning notes
sync.Mutex源码解读




![[speed pointer] 142 circular linked list II](/img/f8/222a360c01d8ef120b61bdd2025044.jpg)



