Share my c code, 4lines, and why does it slow?


  • 0
    K

    #define max(a, b) (a > b ? a : b)
    #define min(a, b) (a > b ? b : a)

    int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) {

    int r = (C - A) * (D - B) + (G - E) * (H - F);
    
    if (!(A >= G || C <= E || B >= H || D <= F))
        r -= (min(C, G) - max(A, E)) * (min(D, H) - max(B, F));
    return r;
    

    }


Log in to reply
 

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