Don’t worry, unlock all articles / blogs on PrepInsta by just simply logging in on our website
Question 1
August 24, 2020
Question 1
Given eight integers A, B, C, D, E, F , G and H which represents two rectangles in a 2D plane. For the first rectangle it’s a bottom left corner is(A,B) and top right corner is (C,D) and for the second rectangle, it’s bottom left corner is (E,F) and top right corner is (G,H). Find and returns whether the two rectangles overlap or not.
Input Format:
8 space separated integers in a single line in the order A, B, C, D, E, F, G and H
Constraints
1 <= A,B,C,D,E,F,G,H <= 10
Output Format
A single integer 1 if the two rectangles overlap else return 0
Code for the above Problem
Python
Python
A, B, C, D, E, F, G, H = map(int, input().split())
if (A >= G) or (E >= C):
print("0") #No_overlapping
else:
print("1") #Overlapping
Login/Signup to comment