技术栈

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

Mopes__2024-07-20 12:21

题目:

题解:

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
上一篇:服务器借助笔记本热点WIFI上网
下一篇:huawei USG6001v1学习---防火墙相关知识(2)
相关推荐
用户372157426135
17 小时前
如何使用Python高效转换Excel到HTML
python
ashuicoder
17 小时前
Python 函数传参与 JavaScript 对比
python
kyle-fang
18 小时前
pytorch-张量
人工智能·pytorch·python
PKNLP
18 小时前
11.大模型Agent应用
python·agent·pip
woshihonghonga
18 小时前
Dropout提升模型泛化能力【动手学深度学习:PyTorch版 4.6 暂退法】
人工智能·pytorch·python·深度学习·机器学习
java1234_小锋
18 小时前
PyTorch2 Python深度学习 - 循环神经网络(RNN)实例
python·rnn·深度学习·pytorch2
Danceful_YJ
18 小时前
28. 门控循环单元(GRU)的实现
pytorch·python·深度学习
三排扣
18 小时前
手搓transformer
pytorch·python·transformer
ZhengEnCi
18 小时前
P3B-90%初学者参数传错位置?合格程序员都这样选择参数类型
python
程序员晚枫
18 小时前
Python处理Excel的5个“神仙库”,办公效率直接翻倍!
python·excel
热门推荐
01GitHub 镜像站点02UV安装并设置国内源03综合整理:pdf预览显示:你尝试预览的文件可能对你的计算机有害。如果你信任此文件以及其来源,请打开此文件以看其内容,如何解决以正常预览文件04Linux下V2Ray安装配置指南05安娜的档案(Anna’s Archive) 镜像网站/国内最新可访问入口(持续更新)06BongoCat - 跨平台键盘猫动画工具07npm使用国内淘宝镜像的方法08《大数据技术原理与应用》实验报告三 熟悉HBase常用操作09jdk21下载、安装(Windows、Linux、macOS)10NVIDIA显卡驱动、CUDA、cuDNN 和 TensorRT 版本匹配指南