Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Widest Vertical Area Between Two Points Containing No Points

XPChallenge Points: 10
levelLevel: Easy

You are given a list of points on a 2D plane, where each point is represented as [x, y].
Your task is to determine the maximum width of a vertical strip (i.e., an area spanning infinitely in the y-direction) such that no points lie inside that strip.

A vertical strip is formed between two distinct x-coordinates.
Points lying exactly on the strip’s boundary do not count as being inside.

Return the largest possible width of such an empty vertical region.

Example 1:

Input: points = [[2,3],[6,8],[4,1],[10,5]]

Output: 4

Explanation:

Sorted x-values = [2,4,6,10] Gaps = [2,2,4] Maximum vertical gap without any points inside = 4.

Example 2:

Input: points = [[1,5],[4,2],[7,9],[8,3],[12,6]]

Output: 4

Explanation:

Sorted x-values = [1,4,7,8,12] Gaps = [3,3,1,4] Maximum width = 5 (between x = 7 and x = 12 → width 5).

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result