leetcode 链接:https://leetcode-cn.com/problems/er-wei-shu-zu-zhong-de-cha-zhao-lcof/
题目

解法
class Solution {public boolean findNumberIn2DArray(int[][] matrix, int target) {// 可以从左上角或者右下角开始查找// 左上角:大于当前值往下移动,小于当前值往左移动// 右上角:大于当前值往右移动,小于当前值往上移动// 对输入进行检测if (matrix.length == 0 || matrix[0].length == 0){return false;}int height = matrix.length;int width = matrix[0].length;// 此处从左上角进行查找int h = 0;int w = width - 1;while (h < height && w >= 0){if (matrix[h][w] == target){return true;} else if (matrix[h][w] > target){w--;} else {h++;}}return false;}}
