【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)
相关推荐
weixin_5806140015 小时前
MySQL存储过程中如何防止SQL注入_使用参数化查询规范
jvm·数据库·python
2401_8371638915 小时前
PHP源码开发用台式机还是笔记本更合适_硬件选型对比【方法】
jvm·数据库·python
zuowei288915 小时前
华为网络设备配置文件备份与恢复(上传、下载、导出,导入)
开发语言·华为·php
baidu_3409988215 小时前
mysql修改列名会导致程序报错吗_Change Column语法与兼容性
jvm·数据库·python
xiaohe0715 小时前
超详细 Python 爬虫指南
开发语言·爬虫·python
Bruceoxl15 小时前
【人物传记】Python 之父-吉多·范罗苏姆
python·计算机·人物传记
嗑嗑嗑瓜子的猫15 小时前
Java!它值得!
java·开发语言
NotFound48616 小时前
实战分享Python爬虫,如何实现高效解析 Web of Science 文献数据并导出 CSV
前端·爬虫·python
xiaoshuaishuai816 小时前
C# GPU算力与管理
开发语言·windows·c#
234710212716 小时前
4.14 学习笔记
笔记·python·学习