one line solution python


  • 0
    D
    class Solution(object):
        def computeArea(self, A, B, C, D, E, F, G, H):
            return (C-A)*(D-B)+(G-E)*(H-F)-(sorted([A,C,E,G])[2]-sorted([A,C,E,G])[1])*(sorted([B,D,F,H])[2]-sorted([B,D,F,H])[1]) if sorted([A,C,E,G])[1]>=A and sorted([A,C,E,G])[2]<=C and sorted([B,D,F,H])[1]>=B and sorted([B,D,F,H])[2]<=D else (C-A)*(D-B)+(G-E)*(H-F)
    

Log in to reply
 

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