Simple C++ Solution


  • 0
    J
    class Solution {
    public:
        vector<int> constructRectangle(int area) {
            int W = sqrt(area);
            while(area % W)
                W--;
            vector<int> result;
            result.push_back(area / W);
            result.push_back(W);
            return result;
        }
    };
    

Log in to reply
 

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