【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)
相关推荐
小小测试开发2 小时前
安装 Python 3.10+
开发语言·人工智能·python
KaMeidebaby3 小时前
卡梅德生物技术快报|PD1 单克隆抗体定制配套 N 糖全谱质控开发
前端·人工智能·算法·数据挖掘·数据分析
梦想不只是梦与想3 小时前
Python 中的装饰器
python·装饰器
我叫唧唧波3 小时前
Python+AI 全栈学习笔记
人工智能·python·学习
8Qi83 小时前
LeetCode 235. 二叉搜索树的最近公共祖先(LCA)
算法·leetcode·二叉树·递归·二叉搜索树·lca·迭代
AAA大运重卡何师傅(专跑国道)4 小时前
【无标题】
开发语言·c#
bIo7lyA8v4 小时前
算法稳定性分析中的随机扰动建模的技术8
算法
copyer_xyf4 小时前
Python 异常处理
前端·后端·python
sugar__salt4 小时前
从栈队列数据结构到JS原型面向对象全解
前端·javascript·数据结构
XBodhi.4 小时前
Visual Studio C++ 语法错误: 缺少“;”(在“return”的前面)
开发语言·c++·visual studio