【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)
相关推荐
小白菜又菜1 小时前
Leetcode 3432. Count Partitions with Even Sum Difference
算法·leetcode
cnxy1882 小时前
围棋对弈Python程序开发完整指南:步骤1 - 棋盘基础框架搭建
开发语言·python
落叶,听雪2 小时前
河南建站系统哪个好
大数据·人工智能·python
wuhen_n2 小时前
LeetCode -- 15. 三数之和(中等)
前端·javascript·算法·leetcode
sin_hielo2 小时前
leetcode 2483
数据结构·算法·leetcode
极客小云3 小时前
【生物医学NLP信息抽取:药物识别、基因识别与化学物质实体识别教程与应用】
python·机器学习·nlp
南_山无梅落3 小时前
12.Python3函数基础:定义、调用与参数传递规则
python
程序员-周李斌3 小时前
Java 死锁
java·开发语言·后端
Xの哲學3 小时前
Linux多级时间轮:高精度定时器的艺术与科学
linux·服务器·网络·算法·边缘计算
大头流矢3 小时前
归并排序与计数排序详解
数据结构·算法·排序算法