C++ 3ms solution in 3 lines


  • 0
    P
    vector<int> constructRectangle(int area) {
        int s = sqrt(area);
        while (area % s != 0) s--;
        return vector<int> {area / s, s};
    }

Log in to reply
 

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