int computeArea(int A, int B, int C, int D, int E, int F, int G, int H)
{
int total = (CA) * (DB) + (GE) * (HF);
if (C<=E  A>=G  B>=H  D<=F )
return total;
else
{
vector <int> h;
h.push_back(A);
h.push_back(C);
h.push_back(E);
h.push_back(G);
vector <int> v;
v.push_back(B);
v.push_back(D);
v.push_back(F);
v.push_back(H);
sort(h.begin(), h.end());
sort(v.begin(), v.end());
total = total  (h[2]  h [1]) * (v[2]  v[1]);
return total;
}
}
My easy c++ solution


your method is so clean and beautiful~!
but the sorting part slow down a little bit.
int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) { int temp,total = (CA) * (DB) + (GE) * (HF); if (C<=E  A>=G  B>=H  D<=F ) return total; else { if(A>C) { temp=A; A=C; C=temp; } if(E>G) { temp=E; E=G; G=temp; } if(B>D) { temp=B; B=D; D=temp; } if(F>H) { temp=F; F=H; H=temp; } total = total  ( min(C,G)  max(A,E))*(min(D,H) max(B,F)); return total; } }