👨🏫 搜索二维矩阵
✨ AC code
class Solution {
public boolean searchMatrix(int[][] matrix, int target)
{
int l = 0;
int row = matrix.length;
int col = matrix[0].length;
int r = row * col - 1;
while (l < r)
{
int m = l + r >> 1;
int x = m / col;
int y = m % col;
if (matrix[x][y] >= target)
r = m;
else
l = m + 1;
}
if (matrix[l / col][l % col] == target)
return true;
return false;
}
}