![]() |
Given a rectangle of length l and breadth b, we need to find the area of the smallest square which can be formed with the rectangles of these given dimensions. Input : 1 2 Output : 4 We can form a 2 x 2 square using two rectangles of size 1 x 2. Input : 7 10 Output :4900
Let’s say we want to make a square of side length a from rectangles of length l & b. This means that a is a multiple of both l & b. Since we want the smallest square, it has to be the lowest common multiple (LCM) of l & b. C++
Javascript
Output:
144
Time Complexity: O(log(min(l,b))) Auxiliary Space: O(log(min(l, b))) |
Reffered: https://www.geeksforgeeks.org
Geometric |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 8 |