← Questions

Line reflection symmetry with duplicate points

0
NuroCodingLast asked Feb 2026

A coding interview question asked in Nuro's technical phone screen, last asked Feb 2026. It tests hashing and geometry.

Given points in the plane, possibly with duplicates, decide whether some vertical line reflects the set onto itself. Duplicates count: every occurrence of a point needs a matching occurrence of its reflection.

Interface

Unless you agree on a different interface with the interviewer, assume:

  • has_vertical_symmetry(points: list[list[int]]) -> bool
  • The line is x = c, where c may be a half-integer; (x, y) reflects to (2c - x, y). Points on the line reflect to themselves. The empty set is symmetric.

Example

has_vertical_symmetry([[1, 2], [3, 2], [2, 4]])          ->  True     # x = 2
has_vertical_symmetry([[0, 1], [1, 1]])                  ->  True     # x = 0.5
has_vertical_symmetry([[0, 0], [0, 0], [2, 0]])          ->  False    # (0, 0) twice, (2, 0) once
has_vertical_symmetry([[1, 1], [-1, 1], [1, 1], [-1, 1]]) ->  True    # x = 0, counts match
has_vertical_symmetry([])                                ->  True

Constraints

  • 0 <= len(points) <= 2 · 10^5
  • Coordinates are integers in [-10^9, 10^9]; 2c - x can exceed 32 bits.

Clarifying questions

  • Do duplicate points count separately?
  • Can the line fall between integer coordinates?
  • What should an empty input return?

What a strong answer covers

  • The only possible line is halfway between the smallest and the largest x, so s = min_x + max_x is fixed; working with 2c = s keeps everything in integers.
  • Counting points in a hash map and checking that each (x, y) and (s - x, y) have the same count; O(n) time and space.
  • Points on the line pair with themselves.
  • A sorting alternative: group by y, sort the x values and check pairs from both ends.
  • Tests with the examples, all points on one vertical line, and large coordinates.

Follow-ups

  • Check for a horizontal line as well, or for any line.
  • Ignore duplicates (treat the points as a set). What changes?
  • Find the line that makes the most points symmetric when no perfect line exists.

Where it's asked

  • Nuro · Technical phone screen · Last asked Feb 2026

What it tests

hashing · geometry

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding