Skip to content

Files

Latest commit

author
Shuo
Feb 16, 2022
ce6b544 · Feb 16, 2022

History

History

line-reflection

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Feb 16, 2022
Nov 12, 2019
Nov 12, 2019

< Previous                  Next >

Given n points on a 2D plane, find if there is such a line parallel to y-axis that reflect the given points.

Example 1:

Input: [[1,1],[-1,1]]
Output: true

Example 2:

Input: [[1,1],[-1,-1]]
Output: false

Related Topics

[Array] [Hash Table] [Math]

Similar Questions

  1. Max Points on a Line (Hard)
  2. Number of Boomerangs (Medium)

Hints

Hint 1 Find the smallest and largest x-value for all points.
Hint 2 If there is a line then it should be at y = (minX + maxX) / 2.
Hint 3 For each point, make sure that it has a reflected point in the opposite side.