public class Solution {
public int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) {
int total=(C-A)*(D-B)+(G-E)*(H-F);
return total-getIntersect(A,C,E,G)*getIntersect(B,D,F,H);
}
public int getIntersect(int x1,int x2, int x3, int x4){
if(x2<x3||x1>x4)return 0;
return Math.abs(Math.max(x1,x3)-Math.min(x2,x4));
}
}