MCPcopy Index your code
hub / github.com/qiyuangong/leetcode / computeArea

Method computeArea

java/223_Rectangle_Area.java:2–8  ·  view source on GitHub ↗
(int A, int B, int C, int D, int E, int F, int G, int H)

Source from the content-addressed store, hash-verified

1class Solution {
2 public int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) {
3 // https://leetcode.com/problems/rectangle-area/discuss/62149/Just-another-short-way
4 // Possible overlap area
5 int left = Math.max(A, E), right = Math.max(Math.min(C, G), left);
6 int bottom = Math.max(B, F), top = Math.max(Math.min(D, H), bottom);
7 return (C - A) * (D - B) - (right - left) * (top - bottom) + (G - E) * (H - F);
8 }
9}

Callers

nothing calls this directly

Calls 1

maxMethod · 0.80

Tested by

no test coverage detected