1240. Tiling a Rectangle with the Fewest Squares Hard

@problem@discussion
#Dynamic Programming#Backtracking



1/**
2 * [1240] Tiling a Rectangle with the Fewest Squares
3 *
4 * Given a rectangle of size n x m, return the minimum number of integer-sided squares that tile the rectangle.
5 *  
6 * Example 1:
7 * <img alt="" src="https://assets.leetcode.com/uploads/2019/10/17/sample_11_1592.png" style="width: 154px; height: 106px;" />
8 * 
9 * Input: n = 2, m = 3
10 * Output: 3
11 * Explanation: 3 squares are necessary to cover the rectangle.
12 * 2 (squares of 1x1)
13 * 1 (square of 2x2)
14 * Example 2:
15 * <img alt="" src="https://assets.leetcode.com/uploads/2019/10/17/sample_22_1592.png" style="width: 224px; height: 126px;" />
16 * 
17 * Input: n = 5, m = 8
18 * Output: 5
19 * 
20 * Example 3:
21 * <img alt="" src="https://assets.leetcode.com/uploads/2019/10/17/sample_33_1592.png" style="width: 224px; height: 189px;" />
22 * 
23 * Input: n = 11, m = 13
24 * Output: 6
25 * 
26 *  
27 * Constraints:
28 * 
29 * 	1 <= n, m <= 13
30 * 
31 */
32pub struct Solution {}
33
34// problem: https://leetcode.com/problems/tiling-a-rectangle-with-the-fewest-squares/
35// discuss: https://leetcode.com/problems/tiling-a-rectangle-with-the-fewest-squares/discuss/?currentPage=1&orderBy=most_votes&query=
36
37// submission codes start here
38
39impl Solution {
40    pub fn tiling_rectangle(n: i32, m: i32) -> i32 {
41        0
42    }
43}
44
45// submission codes end
46
47#[cfg(test)]
48mod tests {
49    use super::*;
50
51    #[test]
52    fn test_1240() {
53    }
54}
55


Back
© 2025 bowen.ge All Rights Reserved.