1 line c++ solution


  • -1
    S

    int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) {
    return (min(max(A,C),max(E,G))<max(min(A,C),min(E,G)) || min(max(B,D),max(F,H))<max(min(F,H),min(B,D)))? abs((C-A)(D-B))+abs((G-E)(H-F)): abs((C-A)(D-B))+abs((G-E)(H-F))-(min(max(A,C),max(E,G))-max(min(A,C),min(E,G)))*(min(max(B,D),max(F,H))-max(min(F,H),min(B,D)));
    }


  • 2
    S

    You can always write one line code for every program, however there is a thing called readability. If you were the interviewer, would you hire a guy who writes code like that?


Log in to reply
 

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