【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)
相关推荐
WiKiLeaks_successor6 小时前
Scipy库里的众数函数不严谨,我把它重构了。
python·scipy
傻啦嘿哟6 小时前
房产数据对比爬虫:同时爬取链家+贝壳+安居客,做房价横向对比
python
我不会起名字3226 小时前
万字总结Golang入门项目
数据结构·经验分享·算法·golang·项目实战·复盘
6Hzlia6 小时前
【Classic 150 刷题计划】 LeetCode 14. 最长公共前缀 | C++ 纵向扫描法与防越界细节
c++·算法·leetcode
小静AI工程实验室6 小时前
JS 逆向接口 ID 变了?Python 与 Node.js 复现 JSON 大整数精度丢失
javascript·python·node.js
李航19836 小时前
用 DeepDraw 几何引擎开发建筑设计软件(五):创建选择工具
python·3d
传奇开心果编程6 小时前
【Rust入门知识点学与练】第35课:工具链与反馈环——先学会读编译器在说什么
开发语言·学习·rust
Metaphor6926 小时前
使用 Python 设置 Excel 行列自适应 【代码示例】
python·excel
重生之小比特7 小时前
【Java SE】字符串 - String类
java·开发语言·intellij-idea
Niuguangshuo14 小时前
论文解读:CTC,端到端序列识别的开山之作
算法·语音识别