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

Page countdown

A new micro ORM open source framework

Support multi-mode polymorphic gbase 8C database continuous innovation and heavy upgrade

YOLOv5添加注意力机制
![[to be continued] [UE4 notes] L1 create and configure items](/img/20/54ba719be2e51b7db5b7645b361e26.jpg)
[to be continued] [UE4 notes] L1 create and configure items
![[merge array] 88 merge two ordered arrays](/img/e9/a73d9f22eead8e68c1e45c27ff6e6c.jpg)
[merge array] 88 merge two ordered arrays

对象的序列化
![[转]MySQL操作实战(三):表联结](/img/70/20bf9b379ce58761bae9955982a158.png)
[转]MySQL操作实战(三):表联结

Grail layout and double wing layout

读者写者模型
随机推荐
Talking about JVM (frequent interview)
win下一键生成当日的时间戳文件
[轉]: OSGI規範 深入淺出
[turn]: Apache Felix framework configuration properties
利用HashMap实现简单缓存
[trans]: spécification osgi
object serialization
Csp-j-2020-excellent split multiple solutions
支持多模多态 GBase 8c数据库持续创新重磅升级
Reverse one-way linked list of interview questions
Embedded database development programming (V) -- DQL
注解与反射
[转]:Apache Felix Framework配置属性
Heap sort summary
Haut OJ 1321: mode problem of choice sister
Haut OJ 2021 freshmen week II reflection summary
kubeadm系列-02-kubelet的配置和启动
对象的序列化
Optimization scheme of win10 virtual machine cluster
SAP method of modifying system table data