题目描述
blablabla
样例
blablabla
算法1
(二分) $O(log(mn))$
参考文献
Java 代码
class Solution {
public boolean searchMatrix(int[][] matrix, int target) {
int m = matrix.length;
int n = matrix[0].length;
int lo = 0;
int hi = m*n-1;
while(lo <= hi){
int mid = lo + (hi-lo>>1);
int pivot = matrix[mid/n][mid%n];
if(pivot == target){
return true;
}else if(pivot < target){
lo++;
}else{
hi--;
}
}
return false;
}
}