C++ Simplest 1-Liner


  • 0
    M
    class Solution {
    public:
        vector<int> constructRectangle(int area) {
            for (int w = sqrt(area); w >= 1; --w) if (area % w == 0) return {area / w, w};
        }
    };
    

Log in to reply
 

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