-
Notifications
You must be signed in to change notification settings - Fork 160
/
tiling-a-rectangle-with-the-fewest-squares.md
39 lines (28 loc) · 1.24 KB
/
tiling-a-rectangle-with-the-fewest-squares.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<p>Given a rectangle of size <code>n</code> x <code><font face="monospace">m</font></code>, find the minimum number of integer-sided squares that tile the rectangle.</p>
<p> </p>
<p><strong>Example 1:</strong></p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2019/10/17/sample_11_1592.png" style="width: 154px; height: 106px;" /></p>
<pre>
<strong>Input:</strong> n = 2, m = 3
<strong>Output:</strong> 3
<strong>Explanation:</strong> <code>3</code> squares are necessary to cover the rectangle.
<code>2</code> (squares of <code>1x1</code>)
<code>1</code> (square of <code>2x2</code>)</pre>
<p><strong>Example 2:</strong></p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2019/10/17/sample_22_1592.png" style="width: 224px; height: 126px;" /></p>
<pre>
<strong>Input:</strong> n = 5, m = 8
<strong>Output:</strong> 5
</pre>
<p><strong>Example 3:</strong></p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2019/10/17/sample_33_1592.png" style="width: 224px; height: 189px;" /></p>
<pre>
<strong>Input:</strong> n = 11, m = 13
<strong>Output:</strong> 6
</pre>
<p> </p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= n <= 13</code></li>
<li><code>1 <= m <= 13</code></li>
</ul>