This problem gives you a set of points on a 2D plane. You need to find the maximum width of a vertical area between two points such that no other points are inside that area. A vertical area is an area of infinite height extending along the y-axis. Effectively, you only care about the x-coordinates of the points and the largest gap between any two adjacent x-coordinates.
This is a popular "Easy" level question at companies like Amazon and Bloomberg because it tests whether a candidate can filter out irrelevant information. In a 2D plane problem, many beginners get distracted by the y-coordinates. Realizing that the y-coordinates are completely irrelevant to the "vertical width" is the first step toward the correct solution.
The pattern used is Sorting. Since we only care about the vertical width, we extract all x-coordinates, sort them in ascending order, and then find the maximum difference between any two consecutive x-coordinates. The time complexity is dominated by sorting, which is O(N log N).
Points: [[5, 10], [1, 5], [9, 2], [3, 8]].
[5, 1, 9, 3].[1, 3, 5, 9].Always identify which dimensions are relevant to the goal. In geometry problems, "vertical" usually implies a dependence on X, and "horizontal" implies a dependence on Y. Simplify your data as early as possible.