As the problem statement says, the remaining cow feed billboard is situated in front of the lawnmower billboard, potentially obscuring it; therefore, we can split it into six cases to consider.
Images will be used to visualize the cases, so note these things: The red color shows the area covered by the second rectangle (whose borders are black), while the green one represents the area of the first rectangle (whose edges are blue). If two rectangles intersect, the red color will appear as
the cow feed billboard block the lawnmower billboard.
We have to calculate the area of the first rectangle not obscured by the second one. There are 6 cases to consider, illustrated by the images below:
Case 1
In this case, both rectangles have the same coordinates, or the first rectangle lies in the area of the second one, so the answer is 0.
Case 2
Case 3
Case 4
Case 5
Case 6
The sixth case also includes a corner case where two rectangles intersect with their corners. In this case, if the intersection of two rectangles is at the corners (the top/down-left/right corners of the rectangles), we have to calculate the entire area of the first rectangle (the blue-edged
rectangle). The image below illustrates the case: