当前位置:网站首页>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;
}
}
边栏推荐
- [转]MySQL操作实战(一):关键字 & 函数
- [speed pointer] 142 circular linked list II
- Chapter 6 data flow modeling - after class exercises
- 剑指 Offer 05. 替换空格
- [turn]: Apache Felix framework configuration properties
- What is the agile proportion of PMP Exam? Dispel doubts
- Haut OJ 1221: a tired day
- [to be continued] [UE4 notes] L2 interface introduction
- lxml.etree.XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8
- A new micro ORM open source framework
猜你喜欢
Hang wait lock vs spin lock (where both are used)
支持多模多态 GBase 8c数据库持续创新重磅升级
YOLOv5添加注意力機制
Support multi-mode polymorphic gbase 8C database continuous innovation and heavy upgrade
Count sort
质量体系建设之路的分分合合
[depth first search] 695 Maximum area of the island
读者写者模型
[turn to] MySQL operation practice (III): table connection
To the distance we have been looking for -- film review of "flying house journey"
随机推荐
[turn to] MySQL operation practice (III): table connection
Remote upgrade afraid of cutting beard? Explain FOTA safety upgrade in detail
[allocation problem] 455 Distribute cookies
浅谈JVM(面试常考)
sync. Interpretation of mutex source code
SSH password free login settings and use scripts to SSH login and execute instructions
[es practice] use the native realm security mode on es
How can the Solon framework easily obtain the response time of each request?
The present is a gift from heaven -- a film review of the journey of the soul
To the distance we have been looking for -- film review of "flying house journey"
A new micro ORM open source framework
A problem and solution of recording QT memory leakage
Reflection summary of Haut OJ freshmen on Wednesday
卷积神经网络——卷积层
YOLOv5-Shufflenetv2
用STM32点个灯
PMP考生,请查收7月PMP考试注意事项
National teacher qualification examination in the first half of 2022
YOLOv5-Shufflenetv2
GBase数据库助力湾区数字金融发展