【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)
相关推荐
阿里嘎多学长5 小时前
2026-07-22 GitHub 热点项目精选
开发语言·程序员·github·代码托管
吃饱了得干活5 小时前
别再手动解析 LLM 输出了!LangChain 四种结构化输出方案对比
后端·python·langchain
噢,我明白了5 小时前
Java中日期和字符串的处理
java·开发语言·日期
爱刷碗的苏泓舒5 小时前
C 语言 if-else 与 switch-case 分支语句对比
c语言·开发语言
ikun_文5 小时前
Python进阶—函数编程
python·pycharm
MC皮蛋侠客5 小时前
uv 系列(三):依赖、锁文件与环境同步——可重复构建的核心
python·uv
量化吞吐机5 小时前
2026年交易想法转Python,中间先补规则转译
人工智能·python
-银雾鸢尾-5 小时前
C#中的泛型约束
开发语言·c#
用户298698530145 小时前
Python 实现 Excel 与 Markdown 互转的实用指南
后端·python·excel
决战灬6 小时前
langgraph之interrupt(事例篇)
人工智能·python·agent