$T(n) = O(n + m), S(n) = O(1)$
class Solution {
public boolean searchArray(int[][] array, int target) {
if (array == null || array.length == 0 || array[0].length == 0) {
return false;
}
int col = array[0].length - 1;
int row = 0;
while (col >= 0 && row <= array.length - 1) {
if (target < array[row][col]) {
col--;
} else if (target > array[row][col]) {
row++;
} else {
return true;
}
}
return false;
}
}