Share 3 line Java Solution


  • 0
    M
        public int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) {
            long area = (C - A) * (D - B) + (G - E) * (H - F);
            long minTop = Math.min(D, H), maxBot = Math.max(B, F), maxLeft = Math.max(A, E), minRight = Math.min(C, G);
            return (int)(area - Math.max(minTop - maxBot, 0) * Math.max(minRight - maxLeft, 0));
        }
    

Log in to reply
 

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