Give a rectangle, does another rectangle intersects it? If it does print out the intersecting rectangle!
The tricks to detecting if they intersect is to treat x and y axis separately, and then combine both checks in to one.
The trick to getting the intersected rectangle is to realize that any of the two rectangles can be on the left or the right side, so taking max() and min() of both rectangle we can get a correct answer.
Take a look at this code
Categories