Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
//Write a program to find out if two rectangles R1 and R2 are overlapping?
const overlappingRectangle = (
R1x1,
R1x2,
R1y1,
R1y2,
R2x1,
R2x2,
R2y1,
R2y2
) => {
if (R1x2 < R2x1 || R1x1 > R2x2) {
return false;
}
if (R1y2 < R2y1 || R1y1 > R2y2) {
return false;
}
return true;
};
console.log(overlappingRectangle(2, 4, 5, 10, 3, 11, 5, 12));
@ShilpiMaurya

This comment has been minimized.

Copy link
Owner Author

@ShilpiMaurya ShilpiMaurya commented Jan 3, 2021

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment