Minimum area of square holding two identical rectangles | Java implementation of the above approach ; Function to find the area of the square ; Larger side of rectangle ; Smaller side of the rectangle ; Driver code
import java . io . * ; class GFG { static int areaSquare ( int L , int B ) { int large = Math . max ( L , B ) ; int small = Math . min ( L , B ) ; if ( large >= 2 * small ) { return large * large ; } else { return ( 2 * small ) * ( 2 * small ) ; } } public static void main ( String [ ] args ) { int L = 7 ; int B = 4 ; System . out . println ( areaSquare ( L , B ) ) ; } }