Rectangle Overlap English

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Rectangle

Overlap
Problem Statement
Given two axis parallel rectangles, you are tasked with finding out whether the two overlap or not. These
are rectangles which represent the boundaries of a wired, networking grid.

Input Format
Rectangles are given as the top left and the bottom right co-ordinates. The first line has the top left coordinate (x1, y1) and the bottom right co-ordinate (x2, y2) of the first rectangle, each separated by a single
space in that order.
The second line has the top left co-ordinate (x3, y3) and the bottom right co-ordinate (x4, y4) of the second
rectangle, similarly seperated by a single space in that order.
Constraints
-20 <= any co-ordinate <= 20
Output Format
Print in one line overlap if the two rectangles overlap or no overlap if they don't overlap.
Sample Input
0 1 1 0
1 1 2 0

Sample Output

overlap

Explanation
As the two rectangles share a common point 1 1 , they overlap, hence the answer overlap .

You might also like