Given a multiset points of two-dimensional points, where each entry is an [x, y] pair with integer coordinates, implement has_vertical_symmetry(points: list[list[int]]) -> bool to decide whether the multiset can be mirrored across some vertical line.
Such a line has the form , where may be an integer or a half-integer. Reflecting a point across the line produces . A point with maps to itself.
Duplicates must be preserved: for every point [x, y], its multiplicity must equal the multiplicity of its reflected point [2c - x, y]. The order of the input points does not matter. An empty input is symmetric by definition.
Example 1:
Input: points = [[2,5],[6,5],[4,1]]
Output: true
Explanation: With the line , (2,5) and (6,5) reflect into each other, while (4,1) lies on the line.
points = [[2, 5], [6, 5], [4, 1]]true
| 0 | 1 | 2 | 3 | 4 | |
|---|---|---|---|---|---|
| 0 | (2,5) | (6,5) | |||
| 1 | |||||
| 2 | |||||
| 3 | |||||
| 4 | (4,1) |
| key | value |
|---|---|
| [2,5] | 1 |
| [6,5] | 1 |
| [4,1] | 1 |
The input multiset has three points: (2,5), (6,5), and (4,1).
Example 2:
Input: points = [[-2,4],[3,4]]
Output: true
Explanation: The line maps (-2,4) to (3,4) and (3,4) back to (-2,4).
Example 3:
Input: points = [[-5,1],[-5,1],[7,1]]
Output: false
Explanation: The line maps (-5,1) to (7,1), but (-5,1) occurs twice while (7,1) occurs only once.
Constraints:
points = [[2, 5], [6, 5], [4, 1]]true
| 0 | 1 | 2 | 3 | 4 | |
|---|---|---|---|---|---|
| 0 | (2,5) | (6,5) | |||
| 1 | |||||
| 2 | |||||
| 3 | |||||
| 4 | (4,1) |
| key | value |
|---|---|
| [2,5] | 1 |
| [6,5] | 1 |
| [4,1] | 1 |
The input multiset has three points: (2,5), (6,5), and (4,1).