Skip to content

Practice Construct the Rectangle

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

Easy#492
LeetCode Problem

Construct the Rectangle

Problem Statement

Given a positive area, return positive integer dimensions [L, W] with L * W equal to area. Require L >= W, and among valid pairs minimize L - W. The output order is length first, width second.

Source: Construct the Rectangle on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
area = 4
Output
[2,2]

# Example 2

Input
area = 37
Output
[37,1]

# Example 3

Input
area = 122122
Output
[427,286]

Constraints

1 <= area <= 10^7

Related LeetCode Problems

Practice more problems similar to Construct the Rectangle.

Review your practice with PhantomCodeAI

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