Java | Leetcode Java题解之第240题搜索二维矩阵II

题目:

题解:

java 复制代码
class Solution {
    public boolean searchMatrix(int[][] matrix, int target) {
        int m = matrix.length, n = matrix[0].length;
        int x = 0, y = n - 1;
        while (x < m && y >= 0) {
            if (matrix[x][y] == target) {
                return true;
            }
            if (matrix[x][y] > target) {
                --y;
            } else {
                ++x;
            }
        }
        return false;
    }
}
相关推荐
你是理想3 小时前
wait 和notify ,notifyAll,sleep
java·开发语言·jvm
helloworld工程师3 小时前
【微服务】SpringBoot整合LangChain4j 操作AI大模型实战详解
java·eclipse·tomcat·maven
Java&Develop3 小时前
idea里面不能运行 node 命令 cmd 里面可以运行咋回事啊
java·ide·intellij-idea
q567315233 小时前
使用Java的HttpClient实现文件下载器
java·开发语言·爬虫·scrapy
你们补药再卷啦4 小时前
不用额外下载jar包,idea快速查看使用的组件源码
java·ide·intellij-idea
熬夜造bug4 小时前
LeetCode Hot100 刷题笔记(1)—— 哈希、双指针、滑动窗口
笔记·leetcode·hot100
爱的叹息4 小时前
Spring Boot 自定义配置类(包含字符串、数字、布尔、小数、集合、映射、嵌套对象)实现步骤及示例
java·linux·spring boot
@西瓜@5 小时前
JAVAEE(多线程-线程池)
java·开发语言
returnShitBoy5 小时前
Go语言中的垃圾回收是如何工作的?
java·jvm·golang
有什么东东6 小时前
山东大学软件学院创新项目实训开发日志(9)之测试前后端连接
java