240. 搜索二维矩阵 II

1
2
3
4
5
6
7
class Solution:
def searchMatrix(self, matrix: List[List[int]], target: int) -> bool:
for row in matrix:
idx = bisect.bisect_left(row,target)
if idx>=0 and idx<len(row) and row[idx]==target:
return True
return False