![]() |
VOOZH | about |
Given an array arr[] consisting of (4 * N + 1) pairs of coordinates representing the coordinates of the corners of any N squares such that only one coordinate doesn't belong to any square, the task is to find that coordinate that doesn't belong to any square.
Examples:
Input: N = 2, arr[] = { {0, 0}, {0, 1}, {0, 2}, {1, 0}, {1, 1}, {1, 2}, {2, 0}, {2, 1}, {2, 2} }
Output: 1 1
Explanation:
The square has four sides: x = 0, x = 2, y = 0, y = 2, now all the points belong to the square except one point (1, 1).Input: N = 2, arr[] = { {0, 0}, {0, 1}, {0, 2}, {1, 0}, {0, 3}, {1, 2}, {2, 0}, {2, 1}, {2, 2} }
Output: 0 3
Approach: The given problem can be solved based on the following observations:
Follow the steps below to solve the problem :
Below is the implementation of the above approach:
1 1
Time Complexity: O(N2)
Auxiliary Space: O(1)