Skip to content
LC-1637 Easy LeetCode

1637. Widest Vertical Area Between Two Points Containing No Points

Read the full problem statement on LeetCode.
Difficulty: easy Acceptance: 87% Topics: Array, Sorting
View full problem on LeetCode
Reference solution (spoiler · python)
# Time:  O(nlogn)
# Space: O(n)

import itertools


class Solution(object):
    def maxWidthOfVerticalArea(self, points):
        """
        :type points: List[List[int]]
        :rtype: int
        """
        sorted_x = sorted({x for x, y in points})
        return max([b-a for a, b in itertools.izip(sorted_x, sorted_x[1:])] + [0])

Solution from kamyu104/LeetCode-Solutions · MIT