当前位置:网站首页>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;
}
}
边栏推荐
猜你喜欢

The present is a gift from heaven -- a film review of the journey of the soul

质量体系建设之路的分分合合

A misunderstanding about the console window

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

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

Palindrome (csp-s-2021-palin) solution
![[turn to] MySQL operation practice (I): Keywords & functions](/img/b1/8b843014f365b786e310718f669043.png)
[turn to] MySQL operation practice (I): Keywords & functions

object serialization
![[to be continued] [UE4 notes] L2 interface introduction](/img/0f/268c852b691bd7459785537f201a41.jpg)
[to be continued] [UE4 notes] L2 interface introduction

sync.Mutex源码解读
随机推荐
Warning using room database: schema export directory is not provided to the annotation processor so we cannot export
FVP和Juno平台的Memory Layout介绍
剑指 Offer 53 - I. 在排序数组中查找数字 I
二十六、文件系统API(设备在应用间的共享;目录和文件API)
Add level control and logger level control of Solon logging plug-in
The present is a gift from heaven -- a film review of the journey of the soul
PMP考试敏捷占比有多少?解疑
Yolov5 ajouter un mécanisme d'attention
利用HashMap实现简单缓存
[to be continued] [UE4 notes] L1 create and configure items
Haut OJ 1221: a tired day
YOLOv5添加注意力機制
Support multi-mode polymorphic gbase 8C database continuous innovation and heavy upgrade
After setting up the database and website When you open the app for testing, it shows that the server is being maintained
C language Essay 1
Service fusing hystrix
[binary search] 34 Find the first and last positions of elements in a sorted array
剑指 Offer 09. 用两个栈实现队列
Haut OJ 1241: League activities of class XXX
软件测试 -- 0 序