C# solution


  • 0
    H
    public int[] ConstructRectangle(int area) {
            int w = 0;
            for(w = (int)Math.Floor(Math.Sqrt(area)); w > 1 && (area % w != 0); w--) ;
            
            return new int[] {area / w, w};
        }
    

Log in to reply
 

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