
题解一:
二叉搜索树:从矩阵右上角观察,结构类似二叉搜索树,因此可以用类似的解法来做。具体做法是双指针从右上角开始,向左下角逐步搜索,如果当前值比目标值大,则向下移动,如果当前值比目标值小,则向左移动。直到找到目标值或指针出界。
class Solution {
    public boolean searchMatrix(int[][] matrix, int target) {
        int m = matrix.length;
        int n = matrix[0].length;
        for (int i = 0, j = n - 1; i < m && j >= 0; ) {
            if (matrix[i][j] > target) j--;
            else if (matrix[i][j] < target) i++;
            else if (matrix[i][j] == target) return true;
        }
        return false;
    }
} 
                












![[mmucache]-ARMV8-aarch64的虚拟内存(mmutlbcache)介绍-概念扫盲](https://img-blog.csdnimg.cn/cc002cbd5c414c5393e19c5e0a0dbf20.gif#pic_center)





