492. Construct the Rectangle¶ Time: $O(n)$ Space: $O(1)$ C++Java 1 2 3 4 5 6 7 8 9 10 11class Solution { public: vector<int> constructRectangle(int area) { int width = sqrt(area); while (area % width) --width; return {area / width, width}; } }; 1 2 3 4 5 6 7 8 9 10class Solution { public int[] constructRectangle(int area) { int width = (int) Math.sqrt(area); while (area % width > 0) --width; return new int[] {area / width, width}; } }