Solution with 3 lines in C++

  • 0

    My solution:

    class Solution {
        int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) {
            int l = (min(C,G)>max(A,E))?(min(C,G)-max(A,E)): 0;
            int h = (min(D,H)>max(B,F))?(min(D,H)-max(B,F)): 0;
            return (C-A)*(D-B)+(G-E)*(H-F) - l*h;

Log in to reply

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