Count of smaller rectangles that can be placed inside a bigger rectangle | Java program for the above approach ; Function to count smaller rectangles within the larger rectangle ; If the dimension of the smaller rectangle is greater than the bigger one ; Return the number of smaller rectangles possible ; Driver Code ; Dimension of bigger rectangle ; Dimension of smaller rectangle ; Function call
import java . util . * ; class GFG { static int No_of_rectangles ( int L , int B , int l , int b ) { if ( ( l > L ) || ( b > B ) ) { return - 1 ; } else { return ( L - l + 1 ) * ( B - b + 1 ) ; } } public static void main ( String [ ] args ) { int L = 5 , B = 3 ; int l = 4 , b = 1 ; System . out . println ( No_of_rectangles ( L , B , l , b ) ) ; } }