[LeetCode]Search a 2D Matrix
发布日期:2021-11-22 02:48:56
浏览次数:2
分类:技术文章
本文共 694 字,大约阅读时间需要 2 分钟。
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:
- Integers in each row are sorted from left to right.
- The first integer of each row is greater than the last integer of the previous row.
For example,
Consider the following matrix:
[ [1, 3, 5, 7], [10, 11, 16, 20], [23, 30, 34, 50]]
Given target = 3
, return true
.
参考:
code:
public class Solution74 { public boolean searchMatrix(int[][] matrix, int target) { if(matrix == null || matrix.length==0) return false; int i = 0, j = matrix[0].length-1; while(i=0){ if(target == matrix[i][j]){ return true; } else if(target
转载地址:https://blog.csdn.net/zxdfc/article/details/48731433 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
留言是一种美德,欢迎回访!
[***.207.175.100]2024年04月05日 10时56分24秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
PHP安装eAccelerator
2019-04-27
PHP新的垃圾回收机制:Zend GC详解
2019-04-27
linux上使用strace查看C语言级别的php源码【一种方法】
2019-04-27
ACCEPT()和ACCEPT4()
2019-04-27
php内核探索方法与资源
2019-04-27
PHP安装扩展mcrypt以及相关依赖项 【PHP安装PECL扩展的方法】
2019-04-27
Javascript到PHP加密通讯的简单实现
2019-04-27
德国SNS交友/视频网站Poppen.de的技术架构分享
2019-04-27
UNIX环境编程
2019-04-27
一笔画问题【数据结构-图论】
2019-04-27
红黑树
2019-04-27
安装多个gcc
2019-04-27
Linux0.01内核根目录Makefile注释
2019-04-27
【CSDN2012年度博客之星】需要您的一票,感谢大家的支持
2019-04-27
PHP对于浮点型的数据需要用不同的方法去解决
2019-04-27
Tokyo Cabinet 安装
2019-04-27
Flink在美团的应用与实践听课笔记
2019-04-27
Java多线程的11种创建方式以及纠正网上流传很久的一个谬误
2019-04-27
JDK源码研究Jstack,JMap,threaddump,dumpheap的原理
2019-04-27
Java使用字节码和汇编语言同步分析volatile,synchronized的底层实现
2019-04-27