Non-maximal suppression based simple solution

  • 0
    class Solution {
        int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) {
            int X1 = max(A,E);
            int X2 = min(C,G);
            int Y1 = min(D,H);
            int Y2 = max(B,F);
            int a1 = abs(D-B)*abs(C-A);
            int a2 = abs(H-F)*abs(G-E);
            if(X2<=X1) return a1+a2;
                if(Y2>=Y1) return a1+a2;
                else return a1+a2-(abs(Y2-Y1)*abs(X2-X1));

Log in to reply

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