题目描述
blablabla
样例
blablabla
算法1
(单调扫描) $O(n^2)$
blablabla
时间复杂度分析:blablabla
Python 代码
class Solution(object):
def searchArray(self, array, target):
"""
:type array: List[List[int]]
:type target: int
:rtype: bool
"""
if len(array) == 0 or len(array[0]) == 0:
return False
x = 0
y = len(array[0]) - 1
while(x < len(array) and y >= 0):
if array[x][y] == target:
return True
if array[x][y] > target:
y -= 1
else:
x += 1
return False