Simple JavaScript Solution


  • 0
    /**
     * @param {number} area
     * @return {number[]}
     */
    var constructRectangle = function(area) {
      for(let i = Math.floor(Math.sqrt(area)); i > 0 ; i--) {
        if (area % i == 0) {
          return [area/i, i];
        }
      }
    };

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.