Skip to content

Files

Latest commit

Aug 2, 2024
960ed22 · Aug 2, 2024

History

History
42 lines (26 loc) · 728 Bytes

problem.md

File metadata and controls

42 lines (26 loc) · 728 Bytes

1240.Tiling a Rectangle with the Fewest Squares [Rating: 2241.52]

Given a rectangle of size n x m, find the minimum number of integer-sided squares that tile the rectangle.

Example 1:

img

Input: n = 2, m = 3
Output: 3
Explanation: 3 squares are necessary to cover the rectangle.
2 (squares of 1x1)
1 (square of 2x2)

Example 2:

img

Input: n = 5, m = 8
Output: 5

Example 3:

img

Input: n = 11, m = 13
Output: 6

Constraints:

  • 1 <= n <= 13
  • 1 <= m <= 13