public class Solution {
    public static boolean find(int target, int [][] array) {
        if (array == null)
            return false;
        int rows = array.length;
        if (rows == 0)
            return false;
        int cols = array[0].length;
        if (cols == 0)
            return false;
        // 定位到右上
        int row = 0;
        int col = cols - 1;
        while (row < rows && col >= 0) {
            if (array[row][col] > target) {
                col--;
            } else if (array[row][col] < target) {
                row++;
            } else {
                return true;
            }
        }
        return false;
    }
}