The title

Points [I] = [xi, yi]; return the width of the widest vertical area between two points without any point inside.

Vertical area is defined as an area of fixed width that extends indefinitely along the Y-axis (i.e., its height is infinite). The widest vertical area is the one with the largest width.

Note that the points on the edge of the vertical region are not in the region.

Example 1: inputs: points = [[8,7],[9,9],[7,4],[9,7]] output: 1 description: the red area and the blue area are both optimal. Example 2: input: points = [(3, 1), (9, 0), (1, 0], [1, 4], [5], [8]] output: 3Copy the code

Tip:

n == points.length 2 <= n <= 105 points[i].length == 2 0 <= xi, yi <= 109

Their thinking

class Solution: def maxWidthOfVerticalArea(self, points: List[List[int]]) -> int: XPoints = [I for I,_ in points] xpoint.sort (reverse=True) for index,val in enumerate(XPoints): XPoints = [I for I,_ in points] xpoint.sort (reverse=True) for index,val in enumerate(XPoints): if index ! = (len(XPoints)-1): XPoints[index] = XPoints[index]-XPoints[index+1] # print(XPoints[:-1]) return max(XPoints[:-1]) if __name__ == '__main__' : points = [(3, 1), (9, 0), (1, 0], [1, 4], [5], [8]] ret = Solution () maxWidthOfVerticalArea (points) print (ret)Copy the code