Write an efficient algorithm to search for a target value in an m x n matrix where each row is sorted and the first integer of each row is greater than the last integer of the previous row.
Treat the matrix as a flat sorted array of m*n elements. Binary search using virtual index mid, and convert to row/col using row=mid/n, col=mid%n.
- lo=0, hi=m*n-1.
- mid = (lo+hi)/2; row=mid/n, col=mid%n.
- If matrix[row][col]==target return true.
- If < target: lo=mid+1. If > target: hi=mid-1.
- Time Complexity: O(log(M*N))
- Space Complexity: O(1)