0ms c++ solution


  • 0
    V

    class Solution {
    public:
    vector<int> constructRectangle(int area)
    {
    vector<int>res(2,0);
    int k=sqrt(static_cast<double>(area));
    for(int i=1;i<=k;i++)
    {
    if (area%i==0)
    {
    res[0]=area/i;
    res[1]=i;
    }
    }
    return res;
    }
    };


Log in to reply
 

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