Given an array arr[] consisting of N pair of integers representing coordinates of N points, the task is to find the area of the largest rectangle formed by straight lines drawn parallel to X and Y-axis from a given set of points.
Examples:
Input: arr[] = , >
Output: 1
Explanation: The area of the largest rectangle is 1 formed by the coordinates (0, 0), (0, 1), (1, 0), (1, 1).Input: arr[] = , , , >
Output: 8
Explanation: The area of the largest rectangle possible is 8 ( length = 4 and breadth = 2 ) by the coordinates (-2, 0), (2, 0), (2, 2), (-2, 2).
Approach: The problem can be solved using the sorting technique. Follow the steps below to solve the problem:
Below is the implementation of the above approach: