Search a 2D Matrix
Medium · Binary Search · about 15 minutes
Asked at Microsoft, Amazon, Google, Meta, Bloomberg, Two Sigma.
The m × n grid reads in sorted order if you go row by row: each row is ascending, and every row starts with a value larger than the previous row's last value. Decide whether target appears anywhere in the grid, in O(log(m·n)) time.