public class Solution {
public boolean Find(int target, int [][] array) {
int m = array.length;
int n = array[0].length;
int i = 0;
int j = n-1;
boolean res = false;
while(i<m && j>=0){
if(array[i][j] == target){
res = true;
break;
}
else if(array[i][j] > target){
j = j - 1;
}
else{
i = i + 1;
}
}
return res;
}
}
class Solution:
# array 二维列表
def Find(self, target, array):
# write code here
m, n = len(array), len(array[0])
i, j = 0, n-1
while i < m and j >= 0:
if array[i][j] == target:
return True
elif array[i][j] < target:
i += 1
else:
j -= 1
return False