【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)
相关推荐
Ares-Wang9 分钟前
Vue3》》eslint Prettier husky
开发语言·javascript·ecmascript
EveryPossible24 分钟前
静态箭头连线
开发语言·javascript·ecmascript
NiKo_W26 分钟前
Git 版本回退与撤销修改
开发语言·git·安全
listhi52034 分钟前
Map对象在JavaScript循环中的使用
开发语言·前端·javascript
大可门耳1 小时前
Qt第一课:Qt是什么?相对于其他框架的优劣势是什么
开发语言·qt
·云扬·2 小时前
【Leetcode hot 100】101.对称二叉树
算法·leetcode·职场和发展
西阳未落2 小时前
C语言中的内存函数(memcpy, memmove, memcmp, memset)
c语言·开发语言
代码AI弗森3 小时前
从 IDE 到 CLI:AI 编程代理工具全景与落地指南(附对比矩阵与脚本化示例)
ide·人工智能·矩阵
xchenhao4 小时前
SciKit-Learn 全面分析分类任务 breast_cancer 数据集
python·机器学习·分类·数据集·scikit-learn·svm
axban4 小时前
QT M/V架构开发实战:QFileSystemModel介绍
开发语言·qt·架构