Skip to content

Commit 07dec18

Browse files
authored
Create Rectangle Area
1 parent 0a700df commit 07dec18

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Rectangle Area

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution {
2+
public int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) {
3+
int height = Math.min(D, H) - Math.max(B, F);
4+
int width = Math.min(C, G) - Math.max(A, E);
5+
int area1=(C - A) * (D - B);
6+
int area2=(G - E) * (H - F);
7+
if(E>C || G<A || F>D || H<B ) {
8+
return area1+area2 ;
9+
}
10+
return (area1 + area2) - (height * width);
11+
}
12+
}

0 commit comments

Comments
 (0)