bool searchMatrix(int** matrix, int matrixSize, int* matrixColSize, int target){ if(matrixSize==0 || *matrixColSize==0) return false; int i, left=0, right=(*matrixColSize)-1; for(i=0; i<matrixSize; i++) if(matrix[i][(*matrixColSize)-1] >= target) break; if(i==matrixSize) return false; while(left <= right){ int mid=(left+right)/2; if(matrix[i][mid]>target) right=mid-1; else if(matrix[i][mid]<target) left=mid+1; else return true; } return false; }