C# Quick Solution


  • 0
    H

    public class Solution {

    public int ComputeArea(int A, int B, int C, int D, int E, int F, int G, int H) 
    {
        int overlap = 0;
        if( Math.Min(C,G) > Math.Max(A,E)  && Math.Min(D,H) > Math.Max(B,F) ){
            overlap = (Math.Min(C,G)-Math.Max(A,E))*(Math.Min(D,H)-Math.Max(B,F));
        }
        return (C-A)*(D-B)+(G-E)*(H-F)-overlap;
    }
    

    }


Log in to reply
 

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