public class Solution {
    public boolean Find(int target, int [][] array) {
        int m = array.length;
        int n = array[0].length;
        int r = 0, c = n - 1;
        while(r < m && c > -1) {
            if(array[r][c] == target) {
                return true;
            } else if(target > array[r][c]) {
                r++;
            } else {
                c--;
            }
        }
        return false;
    }
}