Construct the Rectangle Leetcode

Given a specific rectangular web page’s area, your job by now is to design a rectangular web page, whose length L and width W satisfy the following requirements:

You need to output the length L and the width W of the web page you designed in sequence.

Example:

 

Note:
  1. The given area won’t exceed 10,000,000 and is a positive integer
  2. The web page’s width and length you designed must be positive integers.

Solution

According to the requirement 3 difference between L and W should be as small as possible. That is why we will start with the square-root of the area. 

Next : Java interview question Binary Tree Path


References
https://leetcode.com/problems/construct-the-rectangle/

T Tak

Hey ! I'm Tak. I'm a software developer since 2008 and been programming since I was 17 years, started with pascal. I love programming, teaching and building stuff on web.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.