How do I search for a number in a 2d array sorted left to right and top to bottom?
Here’s a simple approach: Start at the bottom-left corner. If the target is less than that value, it must be above us, so move up one. Otherwise we know that the target can’t be in that column, so move right one. Goto 2. For an NxM array, this runs in O(N+M). I think it would … Read more