题解 | #二维数组中的查找#
二维数组中的查找
http://www.nowcoder.com/practice/abc3fe2ce8e146608e868a70efebf62e
-- coding:utf-8 --
class Solution: # array 二维列表 def Find(self, target, array): # write code here rowCount = len(array) colCount = len(array[0]) i = 0 j = colCount-1
while rowCount and colCount:
item = array[i][j]
if item == target:
return True
elif item > target:
j -= 1
else:
i += 1
if j== -1 or i >= (rowCount):
return False
return False