C++ Solution


  • 0

    class Solution {
    public:
    vector<int> constructRectangle(int area) {

        int b;
        for(int i=sqrt(area);i<=area;i++)
        {
            if(area % i == 0)
            {
                b = area/i;
                if(b <= i) {
                    vector<int> sol;
                    sol.push_back(i);
                    sol.push_back(b);
                    return sol;
                }
            }
        }
       
    }
    

    };


Log in to reply
 

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