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
相关推荐
YZJenny11 分钟前
使用conda将python环境打包,移植到另一个linux服务器项目中
python
棉猴11 分钟前
Pygame实现记忆拼图游戏1
python·pygame·游戏编程·python游戏编程·pygame游戏编程
东方佑17 分钟前
Python中将Markdown文件转换为Word
python·c#·word
Emma歌小白44 分钟前
如何定时执行某个程序
后端·python
曹瑞曹瑞1 小时前
Anaconda conda常用命令:从入门到精通
python·conda
伊织code2 小时前
python-docx - 读写更新 .docx 文件(Microsoft Word 2007+ )
python·microsoft·word·docx·python-docx·openxml
羊小猪~~3 小时前
深度学习项目--基于DenseNet网络的“乳腺癌图像识别”,准确率090%+,pytorch复现
网络·人工智能·pytorch·python·深度学习·机器学习·分类
weixin_307779133 小时前
Python带多组标签的Snowflake SQL查询批量数据导出程序
开发语言·python·sql
大模型铲屎官3 小时前
Python 科学计算与机器学习入门:NumPy + Scikit-Learn 实战指南
开发语言·人工智能·python·机器学习·numpy·编程·scikit-learn