Problem statement

https://leetcode.com/problems/line-reflection/

Solution

Find point with smallest and biggest $x$ coordinate in $O(n)$, it this way we evaluate one possible candidate for our reflection line $x = x_0$. Put all point into set, and for every point $(x, y)$ in set check if point $(2\cdot x_0-x, y)$ also in set.

Complexity

Time and space complexity is $O(n)$.

Code

class Solution:
    def isReflected(self, points):
        mid2 = (min(points)[0] + max(points)[0])
        cnt = {tuple(p) for p in points}
        for x, y in cnt:
            if (mid2 - x, y) not in cnt:
                return False
            
        return True