【hot100篇-python刷题记录】【搜索二维矩阵】

R6-二分查找篇

印象题,直接把它转成一维来处理。

python 复制代码
class Solution:
    def searchMatrix(self, matrix: List[List[int]], target: int) -> bool:
        nums=[i for row in matrix for i in row]
        def binfind(the,target):
            low,high=0,len(the)-1
            while low<=high:
                  mid=(low+high)//2
                  if the[mid]==target:
                       return True
                  elif the[mid]>target:
                       high=mid-1
                  else:
                       low=mid+1
            return False
        return binfind(nums,target)
相关推荐
傲世仙尊10 小时前
从磁盘硬件到Ext文件系统-Linux磁盘级文件系统学习笔记
linux·运维·服务器·开发语言·c++
databook10 小时前
Python 常用统计图表实战指南
python·数据分析·数据可视化
wang_yb10 小时前
Python 常用统计图表实战指南
python·数据分析·databook
小羊没烦恼!10 小时前
Memory 记忆设计讨论:为什么 Agent Memory 不能只靠向量数据库?
java·开发语言·windows·算法·c#
黑马程序员毕设11 小时前
基于微信小程序的节目活动报名与管理系统设计与实现
java·开发语言·spring boot·后端·电脑
魔镜er11 小时前
11-循环神经网络
人工智能·pytorch·python·深度学习·神经网络
sunshine22 girl11 小时前
Java学习 java原理
java·开发语言·学习
ysu_031411 小时前
08-二叉树遍历:四种方式详解
c语言·数据结构·算法·leetcode
咸鱼老弟11 小时前
Speculative Decoding(投机采样):大模型"先猜后验",生成速度翻倍
前端·算法·ai编程
Patrick在香港11 小时前
Python 抓香港政府公报 RSS:中英两个 feed 的 guid 零重合,lastBuildDate 停在 2016 年
python·数据处理·数据抓取·香港·rss