easy math problem


  • 1
    L
    public int ComputeArea(int A, int B, int C, int D, int E, int F, int G, int H) {
            var a = Math.Max(A, E);
                var b = Math.Max(B, F);
                var c = Math.Min(C, G);
                var d = Math.Min(D, H);
                var total = (C - A) * (D - B) + (G - E) * (H - F);
                if (c > a && d > b)
                    total -= (c - a) * (d - b);
                return total;
        }
    

Log in to reply
 

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