C++ Solution(32ms)

  • 5
    class Solution {
        int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) {
            int l = min(max(A, E), C);
            int r = min(max(A, G), C);
            int t = min(max(B, H), D);
            int b = min(max(B, F), D);
            return (C-A)*(D-B) + (G-E)*(H-F) - (r-l)*(t-b);

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.