Python•construct-the-rectangle/synced-solution.py
def constructRectangle(area):
w = int(area ** class="syntax-number">0.5)
while area % w != class="syntax-number">0:
w -= class="syntax-number">1
return [area class=class="syntax-string">"syntax-comment">// w, w]
C++•construct-the-rectangle/synced-solution.cpp
class Solution {
public:
vector<int> constructRectangle(int area) {
int w = (int)sqrt(area);
while (area % w != class="syntax-number">0) {
w--;
}
return {area / w, w};
}
};
TypeScript•construct-the-rectangle/synced-solution.ts
function constructRectangle(area: number): number[] {
let w = Math.floor(Math.sqrt(area));
while (area % w !== class="syntax-number">0) {
w--;
}
return [area / w, w];
}