C++ 3 lines


  • 0
    B
    class Solution {
    public:
        vector<int> constructRectangle(int area) {
            int n = sqrt(area);
            while(area % n != 0) n--;
            return vector<int>{area/n, n};
        }
    };

Log in to reply
 

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