【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)
相关推荐
weelinking1 小时前
【2026】08_Claude与版本控制:Git协作技巧
数据库·人工智能·git·python·数据挖掘·交互·cloudera
YL200404266 小时前
048路径总和III
数据结构·dfs
z200509306 小时前
每日简单算法题——————跟着卡尔
算法
踩着两条虫6 小时前
「AI + 低代码」的可视化设计器
开发语言·前端·低代码·设计模式·架构
JoneBB7 小时前
ABAP Webservice连接
运维·开发语言·数据库·学习
scan7247 小时前
智能体多个工具调用
python
2601_957787587 小时前
企业级内容矩阵的安全合规体系构建与技术实现
大数据·安全·矩阵
2401_867623987 小时前
CSS Flex布局中如何设置子元素间距_掌握gap属性的现代用法
jvm·数据库·python
即使再小的船也能远航7 小时前
【Python】安装
开发语言·python
weixin_421725267 小时前
Linux 编程语言全解析:C、C++、Python、Go、Rust 谁更强?
linux·python·go·c·编程语言