使用双指针,从左下角开始寻找,利用行列都是递增的属性去进行遍历

public boolean findNumberIn2DArray(int[][] matrix, int target) {
        if(matrix.length == 0)
            return false;
        int rows = matrix.length;
        int cols = matrix[0].length;

        int bottom = rows-1;
        int left = 0;

        while(bottom >= 0 && left < cols){
            int nowNum = matrix[bottom][left];
            if(nowNum == target){
                return true;
            }else if(nowNum < target){  // 往右找
                left++;
            }else {
                bottom--;  //往上找
            }
        }
        return false;
    }