Skip to content

Commit c6e7cc0

Browse files
authored
Create Solution.java
1 parent 2141e8e commit c6e7cc0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class Solution {
2+
public int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) {
3+
long x = (long) Math.min(C, G) - Math.max(A, E);
4+
long y = (long) Math.min(D, H) - Math.max(B, F);
5+
int intersection = x > 0 && y > 0 ? (int) (x * y) : 0;
6+
return (C - A) * (D - B) + (G - E) * (H - F) - intersection;
7+
}
8+
}

0 commit comments

Comments
 (0)