Beat 95.97% java solution


  • 0
    T
    public class Solution {
        public int[] constructRectangle(int area) {
            int[] result = new int[2];
            int head = (int)Math.sqrt(area);
            for(int i=head;i>=1;i--){
                if(area%i==0){
                    result[1] = i;
                    result[0] = area/i;
                    break;
                }
            }
            return result;
        }
    }

Log in to reply
 

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