Skip to content

Practice Tiling a Rectangle with the Fewest Squares

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#1240
LeetCode Problem

Tiling a Rectangle with the Fewest Squares

Problem Statement

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

Source: Tiling a Rectangle with the Fewest Squares on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
n = 2, m = 3
Output
3

# Example 2

Input
n = 5, m = 8
Output
5

# Example 3

Input
n = 11, m = 13
Output
6

Constraints

1 <= n, m <= 13

Related LeetCode Problems

Practice more problems similar to Tiling a Rectangle with the Fewest Squares.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.