Imagine you're a city planner looking at a map with n buildings represented as points on a 2D plane, where each point points[i] = [xi, yi] has coordinates (x, y).
Your task is to find the widest vertical corridor between any two buildings such that no other buildings obstruct the path. Think of it as finding the widest north-south street you can build!
A vertical area is like an invisible corridor of fixed width that extends infinitely along the y-axis (infinite height). The widest vertical area is the one with maximum width between two x-coordinates.
Important: Buildings exactly on the edge of a corridor don't count as obstructions - they can be right next to the street!
Goal: Return the maximum width of any such vertical corridor.
Input & Output
Visualization
Time & Space Complexity
For each of the nยฒ pairs of points, we check all n points to see if they lie between
Only using a few variables to track maximum distance
Constraints
- n == points.length
- 2 โค n โค 105
- points[i].length == 2
- 0 โค xi, yi โค 109