share my java solution


  • 0
    C
    public int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) {
    	int tr_x = Math.min(C, G), tr_y = Math.min(D, H);
    	int bl_x = Math.max(A, E), bl_y = Math.max(B, F);
        int commonArea = tr_x > bl_x && tr_y > bl_y ? (tr_x - bl_x) * (tr_y - bl_y) : 0;
        return (C - A) * (D - B) + (G - E) * (H - F) - commonArea; 
    }

Log in to reply
 

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