I don't understand why BS is medium level, but...

```
bool searchMatrix(vector<vector<int> > &matrix, int target)
{
int n = matrix[0].size();
int low = 0, high = matrix.size()*n -1;
while(low <= high)
{
int mid =(high+low)/2;
if(matrix[mid/n][mid%n] < target) low = mid+1;
else if(matrix[mid/n][mid%n] > target) high = mid-1;
else return true;
}
return false;
}
```