> ## Documentation Index
> Fetch the complete documentation index at: https://leetcode-py.wisl.dev/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> leetcode-py is a Python LeetCode practice environment generator with one CLI: lcpy. It is not a service or platform.
> Each problem is a directory under leetcode/ with README.md, solution.py, test_solution.py, helpers.py, and playground.ipynb. lcpy gen creates them from JSON templates bundled with the package.
> Examples are backed by tests; copy them verbatim.

# Widest Vertical Area Between Two Points

> Tested Python solution for LeetCode 1637 with 22 pytest cases. Generate a practice environment with lcpy.

LeetCode 1637, [Easy](/catalog/easy). Topics: [Array](/catalog/topics/array), [Sorting](/catalog/topics/sorting). [View on LeetCode](https://leetcode.com/problems/widest-vertical-area-between-two-points-containing-no-points/description/).

Generate this problem as a practice environment: tested reference solution, 22 [parametrized pytest cases](/practice/testing), and a playground notebook:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
lcpy gen -n 1637   # by problem number
lcpy gen -s widest_vertical_area_between_two_points_containing_no_points   # by problem name
```

## Problem

Given `n` points on a 2D plane where `points[i] = [xi, yi]`, return the widest vertical area between two points such that no points are inside the area.

A vertical area is an area of fixed-width extending infinitely along the y-axis (i.e., infinite height). The widest vertical area is the one with the maximum width.

Note that points on the edge of a vertical area are not considered included in the area.

### Examples

![Example 1](https://assets.leetcode.com/uploads/2020/09/19/points3.png)

```
Input: points = [[8,7],[9,9],[7,4],[9,7]]
Output: 1
Explanation: Both the red and the blue area are optimal.
```

```
Input: points = [[3,1],[9,0],[1,0],[1,4],[5,3],[8,8]]
Output: 3
```

### Constraints

* n == points.length
* 2 \<= n \<= 10^5
* points\[i].length == 2
* 0 \<= xi, yi \<= 10^9

## Solution

Reference implementation from [solution.py on GitHub](https://github.com/wislertt/leetcode-py/blob/main/leetcode/widest_vertical_area_between_two_points_containing_no_points/solution.py), full suite in [test\_solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/widest_vertical_area_between_two_points_containing_no_points/test_solution.py):

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
from itertools import pairwise


class Solution:
    # Time: O(n log n)
    # Space: O(n) for the sorted x-coordinates
    def max_width_of_vertical_area(self, points: list[list[int]]) -> int:
        return max(curr - prev for prev, curr in pairwise(sorted(x for x, _ in points)))
```

## Complexity

| Time | Space |
| - | - |
| O(n log n) | O(n) for the sorted x-coordinates |

## Tags

[NeetCode All](/catalog/neetcode).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.