解法都在代码里,不懂就留言或者私信
二分查找,比较简单
class Solution {
    /**解题思路:每一行有序、每一列也有序,只是整体不是严格有序的,那我们需要找一个点,只能往两个方向走,往一个方向走是变小
    往另外一个方向走是变大,我们右两种选择:左下角的点和右上角的点
    我习惯于用右上角的点 */
    public boolean searchMatrix(int[][] matrix, int target) {
        /**就一个数比较相等不相等就完事了呗 */
        if(matrix.length == 1 && matrix[0].length == 1) {
            return matrix[0][0] == target;
        }
        int curRow = 0;
        int curCol = matrix[0].length - 1;
        /**行是变大的,列是变小的,只有这一种走法,while条件是为了避免越界*/
        while(curRow < matrix.length && curCol >= 0) {
            if(matrix[curRow][curCol] == target) {
                return true;
            } else if(matrix[curRow][curCol] < target) {
                curRow ++;
            } else {
                curCol --;
            }
        }
        /**中间没有返回true说明没找到,这里返回false作为答案 */
        return false;
    }
} 




















