If I have two points say (-4,1) and (-2, 6)
Then reflection of line is (4, 1) and (2, 6).
So For this problem if I have input set = [(-4,1), (-2, 6), (4, 1), (2, 6)]
Then it should return true. But say I've additional point on line which is
not reflected then False.
So I'm thinking simplest O(n^2) solution first, (really didn't understand what question is!)
- For every point I need to find reflected point (-x, same y)
- Then after grouping into two set, need to see in both group each point has same slope?
Is my understanding of question right, if so what I think as brute-force (1) & (2) are right?
[(-4,1), (-2, 6), (4, 1), (2, 6)]
I did not understand the problem at first either.
The input set you gave should return true because the line x=0 is the reflection line. However, I think you misunderstand the problem because the reflection line does not have to be x=0, so the reflect point for (x,y) does not have to be (-x, y). The pair, however, should have same y.
So for example, [[-5,1], [-3, 6], [3, 1], [1, 6]] should return true also. Every point is left-shifted by 1 from the input set you gave. The new reflection line is x=-1.
Hope this helps!