This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
package class009;
public class Code02_SearchA2DMatrixII {
/*
* 评测代码可以直接去leetcode搜索:Search a 2D Matrix II
*
*/
public static boolean searchMatrix(int[][] m, int target) {
if (m == null || m.length == 0 || m[0] == null || m[0].length == 0) {
return false;
}
int N = m.length;
int M = m[0].length;
int row = 0;
int col = M - 1;
while (row < N && col >= 0) {
if (m[row][col] > target) {
col--;
} else if (m[row][col] < target) {
row++;
} else {
return true;