Method
computeArea
(int A, int B, int C, int D, int E, int F, int G, int H)
Source from the content-addressed store, hash-verified
| 1 | class 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
Tested by
no test coverage detected