434. Line Reflection

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.

Example 1:

Input: points = [[1,1],[-1,1]]

Output: true

Explanation:

We can choose the line x = 0.

Example 2:

Input: points = [[1,1],[-1,-1]]

Output: false

Explanation:

We can't choose a line.

Now Your Turn!

Pick the correct output for the given input

Input: points = [[5,1],[5,-1]]

Still unsure what the problem is asking ?

Let’s go through a few more examples, step by step, to make it clearer.

Constraints:

  • n == points.length
  • 1 <= n <= 104
  • -108 <= points[i][j] <= 108

Hints

Frequently Occurring Doubts

Interview Follow-up Questions

Fun Facts

0
class Solution {
public:
bool isReflected(vector<vector<int>>& points) {
// Your code goes here
}
};
Test Case

Input:

Points