My solution in C++ with readability


  • 0
    P

    '''
    class Solution {
    public:
    ==int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) {
    ====long long a = A, b = B, c = C, d = D, e = E, f = F, g = G, h = H;
    ====long long hor = min(c, g) - max(a, e), ver = min(d, h) - max(b, f);
    ====return llabs((c - a) * (d - b)) + llabs((g - e) * (h - f)) - max(0LL, hor) * max(0LL, ver);
    ==}
    };
    '''


Log in to reply
 

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