6ms C accepted


  • 0
    J

    int* constructRectangle(int area, int* returnSize) {
    int *res;
    int i,w,l;
    if(area == 0) return NULL;
    l = (int)sqrt(area);
    for(i = l; i >0 ; i--){
    if(area%i == 0)break;
    }
    w = i;
    l = area/w;
    res = malloc(sizeof(int)*2);
    res[0] = l;
    res[1] = w;
    *returnSize = 2;
    return res;
    }


Log in to reply
 

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