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

题目:

题解:

python 复制代码
class Solution:
    def searchMatrix(self, matrix: List[List[int]], target: int) -> bool:
        m, n = len(matrix), len(matrix[0])
        x, y = 0, n - 1
        while x < m and y >= 0:
            if matrix[x][y] == target:
                return True
            if matrix[x][y] > target:
                y -= 1
            else:
                x += 1
        return False
相关推荐
YFLICKERH几秒前
【多进线程】python多进线程与通信
python
微笑尅乐4 分钟前
三种思路彻底掌握 BST 判断(递归与迭代全解析)——力扣98.验证二叉搜索树
算法·leetcode·职场和发展
程序员爱钓鱼30 分钟前
Python编程实战 · 基础入门篇 | 第一个Python程序:Hello World
后端·python·编程语言
川石课堂软件测试1 小时前
CSS中常用的几种定位。
开发语言·css·python·网络协议·http·html·pytest
C.R.xing2 小时前
Pyspark分布式访问NebulaGraph图数据库
数据库·分布式·python·pyspark·nebulagraph
我是华为OD~HR~栗栗呀2 小时前
华为OD-21届考研-Java面经
java·前端·c++·python·华为od·华为·面试
松果集2 小时前
【2】数据结构·序列构成的数组
python
白云千载尽2 小时前
leetcode 2598 执行操作后最大MEX
算法·leetcode·职场和发展
局外人LZ2 小时前
django rest framework:从零开始搭建RESTful API
python·django·restful·drf
㏕追忆似水年华あ2 小时前
逻辑600解析本03
python·flask