My 4 line Python solution

  • 0
    def computeArea(self, A, B, C, D, E, F, G, H):
        x=0 if max(abs(E-C),abs(G-A))>x1+x2 else min(x1,x2,abs(E-C),abs(G-A))
        y=0 if max(abs(D-F),abs(H-B))>y1+y2 else min(y1,y2,abs(D-F),abs(H-B))
        return x1*y1+x2*y2-x*y

Log in to reply

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