Given n points on a 2D plane, find if there is such a line parallel to the y-axis that reflects the given points symmetrically.In other words, answer whether or not if there exists a line that after reflecting all points over the given line, the original points’ set is the same as the reflected ones.Note that there can be repeated points.
class Solution: # Time: O(n) # Space: O(n) def is_reflected(self, points: list[list[int]]) -> bool: min_x, max_x = min(x for x, _ in points), max(x for x, _ in points) point_set = {(x, y) for x, y in points} s = min_x + max_x return all((s - x, y) in point_set for x, y in points)