当前位置:网站首页>剑指 Offer 04. 二维数组中的查找
剑指 Offer 04. 二维数组中的查找
2022-07-05 05:26:00 【ThE wAlkIng D】
题目描述
问题解析
- 注意二维数组的递增方式,根据递增方式定位左下角作为起始点开始遍历
- 注意.length(针对任意数组,取出它的容量)和.length()(针对字符串)之间的区别
代码实例
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;
}
}
边栏推荐
- PMP candidates, please check the precautions for PMP examination in July
- SAP method of modifying system table data
- A new micro ORM open source framework
- 支持多模多态 GBase 8c数据库持续创新重磅升级
- YOLOv5添加注意力機制
- Introduction to tools in TF-A
- sync.Mutex源码解读
- Page countdown
- Es module and commonjs learning notes -- ESM and CJS used in nodejs
- [allocation problem] 135 Distribute candy
猜你喜欢
挂起等待锁 vs 自旋锁(两者的使用场合)
[to be continued] [UE4 notes] L1 create and configure items
Applet live + e-commerce, if you want to be a new retail e-commerce, use it!
Talking about JVM (frequent interview)
[merge array] 88 merge two ordered arrays
Page countdown
[turn]: OSGi specification in simple terms
Remote upgrade afraid of cutting beard? Explain FOTA safety upgrade in detail
[trans]: spécification osgi
Learning notes of "hands on learning in depth"
随机推荐
Collapse of adjacent vertical outer margins
十年不用一次的JVM调用
Programmers' experience of delivering takeout
第六章 数据流建模—课后习题
Corridor and bridge distribution (csp-s-2021-t1) popular problem solution
Binary search basis
High precision subtraction
A new micro ORM open source framework
Applet Live + e - commerce, si vous voulez être un nouveau e - commerce de détail, utilisez - le!
Haut OJ 1241: League activities of class XXX
软件测试 -- 0 序
[turn to] MySQL operation practice (III): table connection
Insert sort
Embedded database development programming (zero)
Haut OJ 1243: simple mathematical problems
Quick sort summary
Hang wait lock vs spin lock (where both are used)
kubeadm系列-00-overview
Simple modal box
A three-dimensional button