I'm having trouble with an algorithm
let's say I have 3 rectangles, the sides of each rectangle are parallel to the x and y axis.
These rectangles can overlap, the goal is to find the area of all rectangles minus the intersection.
I have a few test cases and the area it's supposed to result in
Here's what I tried
I tried calculating the area of each of the 3 rectangles
Then I calculated the intersection between rectangles 1 and 3, 1 and 2 and 2 and 3, and substracted that.
I can't get that result.
Can someone help me out with a hint or what I'm doing wrong with my thought process