![]() |
VOOZH | about |
You are given three points a, b, c on a page. Find if it's possible to rotate the page around the point by an angle, such that the new position of 'a' is same as the old position of 'b', and the new position of 'b' is same as the old position of 'c'. If such angle exists print "Yes", else "No".
Examples:
Input : a1 = 0, a2 = 1, b1 = 1, b2 = 1, c1 = 1, c2 = 0 Output : Yes Explanation : Rotate the page by 90 degree. Input : a1 = 1, a2 = 1, b1 = 0, b2 = 0, c1 = 1000, c2 = 1000 Output : No
Rotation of page by some angle is only possible if the distance between points 'a' and 'b' is equal to distance between points 'b' and 'c'. But if the points are on same line, there is no rotation at point 'b'. The problem has no solution when 'a', 'b', 'c' are in the same line or dis(a, b) != dis(b, c)
Output:
No
Time Complexity: O(logn)
Auxiliary Space: O(1)