LeetCode-74-Search a 2D Matrix 二维二分
来源:互联网 发布:51单片机ad转换 编辑:程序博客网 时间:2024/05/16 23:50
class Solution(object): def searchMatrix(self, matrix, target): """ :type matrix: List[List[int]] :type target: int :rtype: bool """ Len=len(matrix) if Len==0:return False if Len==1:return self.binarySearch(matrix[0],target) l=0 r=Len-1 while(l<r): m=(l+r)/2 if matrix[m][0]<target: l=m+1 else: r=m if matrix[r][0]==target:return True if r==0:return False if matrix[r][0]<target:return self.binarySearch(matrix[r],target) return self.binarySearch(matrix[r-1],target) def binarySearch(self, s, v): Len=len(s) if Len==0:return False l=0 r=Len-1 while(l<r): m=(l+r)/2 if s[m]<v: l=m+1 else: r=m if s[r]==v:return True return False
阅读全文
1 0
- LeetCode-74-Search a 2D Matrix 二维二分
- LeetCode-74-Search a 2D Matrix(二分查找)-Medium
- Leetcode 74 - Search a 2D Matrix(二分)
- [算法][LeetCode]Search a 2D Matrix——二维数组的二分查找
- Leetcode Search a 2D Matrix 搜索二维表
- Leetcode 二分查找 Search a 2D Matrix
- Leetcode 二分查找 Search a 2D Matrix
- leetcode-二分查找:Search a 2D Matrix
- LeetCode Search a 2D Matrix(二分查找法)
- [LeetCode] Search a 2D Matrix(二分查找)
- Leetcode 74 Search a 2D Matrix
- LeetCode 74: Search A 2D Matrix
- LeetCode 74 Search a 2D Matrix
- [leetcode 74] Search a 2D Matrix
- [LeetCode 74]Search a 2D Matrix
- leetcode || 74、Search a 2D Matrix
- leetcode-74 Search a 2D Matrix
- Leetcode[74]-Search a 2D Matrix
- Netty分隔符解码器和定长解码器的应用方案
- 友盟统计 集成测试看不到实时日志
- CSRF的攻击和防范
- 2017.9.20 noip模拟赛 总结
- 为什么Redis没有实现典型的加锁功能?
- LeetCode-74-Search a 2D Matrix 二维二分
- IO流
- 面向对象一些重点
- Leetcode-Remove Duplicates from Sorted Array
- AndroidStudio中使用Git-初级篇(一)——从github上传和下载项目(by 星空武哥)
- SpringMVC 手动控制事务提交 --各种坑
- HDU 1113 Word Amalgamation 《map》
- Qt生成或解析二维码
- linux dstat,slurm,ccze 安装