当前位置:网站首页>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;
}
}
边栏推荐
- Zheng Qing 21 ACM is fun. (3) part of the problem solution and summary
- [turn]: OSGi specification in simple terms
- Improvement of pointnet++
- Reflection summary of Haut OJ freshmen on Wednesday
- lxml.etree.XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8
- 注解与反射
- 剑指 Offer 09. 用两个栈实现队列
- [sum of two numbers] 169 sum of two numbers II - enter an ordered array
- [trans]: spécification osgi
- Haut OJ 1316: sister choice buys candy III
猜你喜欢

Reverse one-way linked list of interview questions

Fragment addition failed error lookup

A misunderstanding about the console window

Acwing 4300. Two operations

剑指 Offer 04. 二维数组中的查找
![[interval problem] 435 Non overlapping interval](/img/a3/2911ee72635b93b6430c2efd05ec9a.jpg)
[interval problem] 435 Non overlapping interval

Introduction to tools in TF-A

支持多模多态 GBase 8c数据库持续创新重磅升级

Using HashMap to realize simple cache

利用HashMap实现简单缓存
随机推荐
Pointnet++ learning
[turn]: OSGi specification in simple terms
YOLOv5添加注意力機制
Palindrome (csp-s-2021-palin) solution
远程升级怕截胡?详解FOTA安全升级
[binary search] 69 Square root of X
[to be continued] I believe that everyone has the right to choose their own way of life - written in front of the art column
搭建完数据库和网站后.打开app测试时候显示服务器正在维护.
After setting up the database and website When you open the app for testing, it shows that the server is being maintained
利用HashMap实现简单缓存
[转]MySQL操作实战(三):表联结
Haut OJ 1357: lunch question (I) -- high precision multiplication
[es practice] use the native realm security mode on es
[allocation problem] 455 Distribute cookies
Reflection summary of Haut OJ freshmen on Wednesday
一个新的微型ORM开源框架
Control Unit 控制部件
浅谈JVM(面试常考)
Drawing dynamic 3D circle with pure C language
游戏商城毕业设计