240. 搜索二维矩阵 II - 力扣LeetCode阶梯搜索class Solution { public boolean searchMatrix(int[][] matrix, int target) { int m matrix.length; int n matrix[0].length; //从右上角开始 int row 0; int col n-1; while(row m-1 col 0){ if(matrix[row][col]target){ return true; } else if(matrix[row][col]target){ row; } else{ col--; } } return false; } }时间复杂度O(m n)空间复杂度O(1)