【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
OPEN-F3 小时前
C++进阶教程:继承与多态
开发语言·c++
鹿角片ljp4 小时前
LeetCode 236. 二叉树的最近公共祖先|递归后序
算法
luj_17684 小时前
大律师考核应重能力与科技素养
c语言·开发语言·c++·经验分享·算法
无定义_4 小时前
Floyd——Warshall
算法
Thomas21435 小时前
Java scala 数组 链表
java·链表·scala
威联通网络存储5 小时前
TS-h3087XU-RP 汽车零部件质检追溯部署
python·汽车
你驴我5 小时前
WhatsApp 多账号场景下的会话归档与历史消息检索优化实践
后端·python
IT毕设实战小研5 小时前
基于安卓的空气质量查询系统
android·大数据·vue.js·爬虫·python·django·课程设计
带多刺的玫瑰5 小时前
Leecode#9刷题之回文数
数据结构·算法