当前位置:网站首页>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;
}
}
边栏推荐
- Acwing 4301. Truncated sequence
- 浅谈JVM(面试常考)
- SSH password free login settings and use scripts to SSH login and execute instructions
- TF-A中的工具介绍
- [depth first search] 695 Maximum area of the island
- Introduction to memory layout of FVP and Juno platforms
- 数仓项目的集群脚本
- 注解与反射
- Es module and commonjs learning notes -- ESM and CJS used in nodejs
- PMP考生,请查收7月PMP考试注意事项
猜你喜欢
Introduction to tools in TF-A
剑指 Offer 35.复杂链表的复制
lxml.etree.XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8
Fragment addition failed error lookup
[转]MySQL操作实战(一):关键字 & 函数
SAP method of modifying system table data
服务熔断 Hystrix
支持多模多态 GBase 8c数据库持续创新重磅升级
[to be continued] [UE4 notes] L1 create and configure items
Talking about JVM (frequent interview)
随机推荐
剑指 Offer 06.从头到尾打印链表
GBase数据库助力湾区数字金融发展
剑指 Offer 09. 用两个栈实现队列
The present is a gift from heaven -- a film review of the journey of the soul
发现一个很好的 Solon 框架试手的教学视频(Solon,轻量级应用开发框架)
每日一题-搜索二维矩阵ps二维数组的查找
Pointnet++的改进
剑指 Offer 04. 二维数组中的查找
Reverse one-way linked list of interview questions
Little known skills of Task Manager
Fragment addition failed error lookup
Haut OJ 1243: simple mathematical problems
Quick sort summary
Heap sort summary
剑指 Offer 05. 替换空格
Programmers' experience of delivering takeout
YOLOv5添加注意力机制
Chapter 6 data flow modeling - after class exercises
[turn]: OSGi specification in simple terms
On-off and on-off of quality system construction