240. 搜索二维矩阵 II


思路

遍历每一行,将当前行的数存放至哈希表中(in的时间复杂度O(1)),查询target是否存在当前行中,是直接返回

遍历结束都找不到target,则说明target不存在

python 复制代码
class Solution(object):
    def searchMatrix(self, matrix, target):
        """
        :type matrix: List[List[int]]
        :type target: int
        :rtype: bool
        """
        for i in range(len(matrix)):
            s = set(matrix[i])
            if target in s:
                return True

        return False
相关推荐
databook37 分钟前
用递归消除法优化“特征子集”
python·机器学习·scikit-learn
CAE二次开发工程师40 分钟前
【C语言入门到精通】-基础篇
c语言·开发语言·python
wangwangmoon_light1 小时前
1.1 灵神题单总结_滑动窗口与双指针
leetcode
森G2 小时前
comfyui安装ComfyUI-Manager失败问题-解决办法
python
过期的秋刀鱼!2 小时前
倾斜数据集的错误指标-混淆矩阵
人工智能·python·深度学习·机器学习·概率论·模型评估
能年玲奈喝榴莲牛奶3 小时前
使用AI编写-资产和漏洞管理系统
人工智能·python·网络安全·安全服务
DeepVisionary3 小时前
再观察小星火:当大厂分成“冰封“,国产轻模式创作者平台如何跑出加速度
python·自动化
gb42152873 小时前
python中unstructured库和langchain-unstructured库在解析pdf文件的时候的区别?
python·langchain·pdf
vx-程序开发4 小时前
django医院预约挂号系统---附源码23353
java·javascript·spring boot·python·eclipse·django·php
Navigator_Z4 小时前
LeetCode //C - 1187. Make Array Strictly Increasing
c语言·算法·leetcode