【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)
相关推荐
Pniubi3 分钟前
Java为什么要分堆和栈
java·开发语言
微尘hjx16 分钟前
【Deep-OC-SORT 02】多轨迹算法Deep-OC-SORT-相对 OC-SORT 的改进点
人工智能·算法·yolo·目标跟踪·视觉检测·ultralytics·deep-oc-sort
梦帮科技17 分钟前
意识启发式量子隧穿退火算法用于全局优化 (CITA) 完整技术指南
网络·人工智能·算法·量子计算·模拟退火算法
用户2986985301428 分钟前
Python 自动化处理 Word 页眉页脚的几种典型场景
后端·python·api
小小晓.38 分钟前
Qt 对话框、QLineEdit 与布局管理实战详解
开发语言·qt
終不似少年遊*41 分钟前
【安全业务Agent】从场景到编排
python·react.js·ai·langchain·agent·安全架构·工作流
AKA__Zas1 小时前
接口自动化测试(1.0 初认识
python·ci/cd·学习方法
炸薯条!1 小时前
博客系统测试报告
开发语言·lua
Evand J1 小时前
【MATLAB例程12】永磁同步电机基于增广无迹卡尔曼滤波的未知负载转矩在线观测
开发语言·matlab
一去不复返的通信er1 小时前
排序 + 双指针:力扣15三数之和
算法·leetcode