StaffBacktracking
Tiling a Rectangle with the Fewest Squares
Given a rectangle of size n x m, return the minimum number of integer-sided squares that tile the rectangle.
Example 1
Input
n = 2, m = 3Output
3Three squares are necessary: two
1x1 squares and one 2x2 square.Example 2
Input
n = 5, m = 8Output
5The
5 x 8 rectangle can be tiled using a minimum of 5 integer-sided squares.Constraints
- 1 <= n, m <= 13