C# solution,1line,beats 96.97%


  • -1
    Z
    public class Solution
    {
        public int ComputeArea(int A, int B, int C, int D, int E, int F, int G, int H)
        {
            return (C <= E || A >= G || B >= H || D <= F)?(C - A) * (D - B) + (G - E) * (H - F):((C - A) * (D - B) + (G - E) * (H - F) - ((C < G ? C : G) - (A < E ? E : A)) * ((H < D ? H : D) - (B > F ? B : F)));
        }
    }

Log in to reply
 

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