My very pythonic solution (120ms though)


  • 3
    B
    def computeArea(self, A, B, C, D, E, F, G, H):
        area1 = abs(C-A)*abs(D-B)
        area2 = abs(G-E)*abs(H-F)
    	
    	# Find the overlapping area
        height = min(D, H) - max(B, F)
        width =  min(C, G) - max(A, E)
        return area1 + area2 - (height>0 and width>0)*height*width

Log in to reply
 

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