C solution


  • 0
    W
    int* constructRectangle(int area, int* returnSize) {
        int* ReturnArray=calloc(2,sizeof(int));
        * returnSize=2;
        int i=sqrt(area);
        while(i){
        	if(!(area%i)){
        		*ReturnArray=area/i;
        		*(ReturnArray+1)=i;
        		break;
        	}
        	i--;
        }
        return ReturnArray;
    }
    

Log in to reply
 

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