技术栈

【hot100篇-python刷题记录】【搜索二维矩阵】

我明天再来学Web渗透2024-08-30 16:55

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)
上一篇:矩阵分块乘法的证明
下一篇:Mysql剖析(四)----Mysql的行锁、表锁、间隙锁详解
相关推荐
金銀銅鐵
17 小时前
[Python] 从《千字文》中随机挑选汉字
后端·python
cup11
21 小时前
[技术复盘] Windows Python 打包实战:Nuitka 环境踩坑总结与 CI 自动化构建全指南
python·ai·环境变量·ci·nuitka·skill
aqi00
1 天前
15天学会AI应用开发(七)有了大模型为什么还要引入RAG
人工智能·python·大模型·ai编程·ai应用
金銀銅鐵
1 天前
用 Python 实现 Take-Away 游戏
python·游戏
copyer_xyf
1 天前
Agent 流程编排
后端·python·agent
copyer_xyf
1 天前
Agent RAG
后端·python·agent
copyer_xyf
1 天前
【RAG】向量数据库:milvus
后端·python·agent
copyer_xyf
1 天前
Agent 记忆管理
后端·python·agent
JieE212
1 天前
LeetCode 56. 合并区间|超清晰 JS 图解思路,面试高频区间题
javascript·算法·面试
热门推荐
012026年6月AI行业全景:从百模大战到Agent元年,这30天发生了什么?022026年6月AI大模型全景报告:GPT-5.6、Claude Opus 4.8、Gemini 3.5,中美AI三足鼎立谁主沉浮?03【AI】2026 年具身智能模型和世界模型总结042026 年 AI 编程工具终极横评:Cursor vs Claude Code vs Copilot vs Windsurf05GitHub 镜像站点06AI科技热点日报 | 2026年6月1日07AI一周事件 · 2026-06-03 至 2026-06-0908Claude Code、Codex、Cursor三分天下:2026年AI编程Agent生态全景剖析09上线仅72小时被强制下架:Claude Fable 5 的短命102026 AI 编程工具终极实战指南:Cursor vs Claude Code vs Copilot,开发者该怎么选?