【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 小时前
GEO 优化到底是什么?AI时代内容创作者必须懂的新技能
算法·面试·github
朝朝辞暮i4 小时前
C++ 第 23 课:class —— 开始真正进入面向对象
开发语言·c++·算法
7yewh4 小时前
SLAM 三维空间刚体运动(2)
数据结构·人工智能·机器人·嵌入式·slam
Evand J4 小时前
【MATLAB例程】三维RRT+APF避障路径规划与到达角(AOA)定位算法|三维路径优化与定位仿真例程
算法·matlab·路径规划·代码·定位·rrt·aoa
leikooo4 小时前
用餐厅和盘子理解栈和堆
java·数据结构·链表·rust
言乐64 小时前
HTML视频审核模型
python·django·virtualenv·pygame·tornado
小师兄吃牛肉4 小时前
C语言篇:宏
c语言·开发语言
郑同学的笔记5 小时前
【c++随笔28】strcmp 和 memcmp对比
开发语言·c++
言乐65 小时前
Python根据无法识别搜索词找出可能输入内容模型
开发语言·python·django·virtualenv·pygame
weixin_307779135 小时前
有限产能智能排产与动态重排智能体:从需求解构到技术实现
开发语言·人工智能·算法·架构