My 1 line C++ solution


  • 4
    B
    class Solution {
    public:
        int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) {
            return (C>E && G>A && H>B && D>F) ? (C-A)*(D-B)+(G-E)*(H-F)-(min(C,G)-max(A,E))*(min(D,H)-max(B,F)) : (C-A)*(D-B)+(G-E)*(H-F);
        }
    };

  • 0
    D

    so cool!!!!!!!!!!!!!!!!!!!!!!!


Log in to reply
 

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