You are given an m x n integer matrix with two properties: Each row is sorted, and the first integer of each row is greater than the last of the previous row. Search for a target in O(log(m * n)) time.
Binary Search
Because of the matrix's sorted properties, it can be visualized as a single 1D sorted array. We can use a standard binary search but map the 1D index back to 2D coordinates using row = index // cols and col = index % cols.