Skip to content

Instantly share code, notes, and snippets.

@ShilpiMaurya
Last active January 3, 2021 11:57
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
Copy link
Author

image

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