当前位置:网站首页>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;
}
}
边栏推荐
- Binary search basis
- sync. Interpretation of mutex source code
- Service fusing hystrix
- Drawing dynamic 3D circle with pure C language
- Under the national teacher qualification certificate in the first half of 2022
- 动漫评分数据分析与可视化 与 IT行业招聘数据分析与可视化
- [turn]: Apache Felix framework configuration properties
- 剑指 Offer 09. 用两个栈实现队列
- After setting up the database and website When you open the app for testing, it shows that the server is being maintained
- Research on the value of background repeat of background tiling
猜你喜欢
To the distance we have been looking for -- film review of "flying house journey"
第六章 数据流建模—课后习题
Binary search basis
Service fusing hystrix
[interval problem] 435 Non overlapping interval
Solution to the palindrome string (Luogu p5041 haoi2009)
[转]: OSGI规范 深入浅出
剑指 Offer 06.从头到尾打印链表
[to be continued] [UE4 notes] L2 interface introduction
Research on the value of background repeat of background tiling
随机推荐
SAP-修改系统表数据的方法
Haut OJ 1241: League activities of class XXX
Corridor and bridge distribution (csp-s-2021-t1) popular problem solution
Solon Logging 插件的添加器级别控制和日志器的级别控制
Software test -- 0 sequence
第六章 数据流建模—课后习题
剑指 Offer 09. 用两个栈实现队列
Detailed explanation of expression (csp-j 2021 expr) topic
Time complexity and space complexity
使用Room数据库报警告: Schema export directory is not provided to the annotation processor so we cannot expor
Solon 框架如何方便获取每个请求的响应时间?
Haut OJ 1350: choice sends candy
Acwing 4300. Two operations
A new micro ORM open source framework
Es module and commonjs learning notes -- ESM and CJS used in nodejs
Haut OJ 1321: mode problem of choice sister
数仓项目的集群脚本
[interval problem] 435 Non overlapping interval
Support multi-mode polymorphic gbase 8C database continuous innovation and heavy upgrade
[binary search] 34 Find the first and last positions of elements in a sorted array