Skip to content

Commit b91bfe0

Browse files
author
zongyanqi
committed
add Easy_492_Construct_the_Rectangle
1 parent b5a02a1 commit b91bfe0

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Easy_492_Construct_the_Rectangle.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@
2828
* @param {number} area
2929
* @return {number[]}
3030
*/
31-
var constructRectangle = function(area) {
31+
var constructRectangle = function (area) {
3232

33-
};
33+
var w = Math.floor(Math.sqrt(area));
34+
while (area % w != 0) w--;
35+
return [area / w, w];
36+
37+
};
38+
39+
console.log(constructRectangle(4));
40+
console.log(constructRectangle(17));

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy