【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)
相关推荐
小雉系统3 小时前
BcoreOS安全通信架构:FsSession 抗算法后门安全设计
算法·安全·架构
§ꦿCFོ༉4 小时前
嵌入式八股文—C语言入门学习(四)
c语言·开发语言·学习
投图匠4 小时前
十种不同风格的 CTP接口 框架
开发语言·python
2601_967980115 小时前
深入理解词向量算法及其在Python中的实践
python·word2vec·glove·fasttext·词向量
Pniubi6 小时前
关于算法用现成数据结构和手撕
数据结构
129Lab6 小时前
电池循环测试数据自动化分析:用Python+AI工具构建一键式寿命评估流水线
python·数据分析·电池测试·数据自动化·寿命评估
treasure1406 小时前
【复古】浅尝Django前后端不分离
前端·css·python·django·bootstrap·html·web
Dmz丶7 小时前
前端转 AI 100 天 Day 44:前端集成实战——用 React 给 Agent 做个正式界面
python
唐墨1237 小时前
linux kernel 比较数据大小的宏定义
linux·算法