My simple C solution


  • 0
    S

    int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) {
    int right = C<G?C:G;
    int left = A<E?E:A;
    int bot = B<F?F:B;
    int top = D<H?D:H;
    int area = (C-A)(D-B)+(H-F)(G-E);
    if (right < left || top < bot) return area;
    return area-(right-left)*(top-bot);
    }


Log in to reply
 

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