Solution 1 - sqrt Search
Start from floor(sqrt(area)) and find the first divisor w; answer is [area/w, w].
""" 0492.1 - Construct the Rectangle - Solution 1 - sqrt Search """
import math
from typing import List
class Solution:
def constructRectangle(self, area: int) -> List[int]:
w = int(math.isqrt(area))
while area % w != 0:
w -= 1
return [area // w, w]
if __name__ == "__main__":
print(Solution().constructRectangle(4)) # [2,2]