Given an array of pairs containing length and breadth of rectangles. The task is to find the maximum area of the rectangle.
Input: (1, 2), (3, 5), (1, 1), (4, 2) Output: 15 Input: (3, 5), (5, 5), (9, 10) Output: 90
- Use user defined Pair class to store Breadth and Height of rectangles.
- Make an array of this class.
- Now, traverse the array and find the area each time. Also, keep track of maximum area.
- Return the maximum area of rectangle.
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.