Leetcode 492 Solution

This article provides solution to leetcode question 492 (construct-the-rectangle)

https://leetcode.com/problems/construct-the-rectangle

Solution

class Solution {
public:
    vector<int> constructRectangle(int area) {
        int k = sqrt(area);

        for (int i = k; i >= 1; --i)
        {
            if (area % i == 0)
                return {area / i, i};
        }

        return {};
    }
};