Skip to content

Instantly share code, notes, and snippets.

@ShilpiMaurya
Last active January 3, 2021 11:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ShilpiMaurya/bcc8e67435776b77531255bac38cbc06 to your computer and use it in GitHub Desktop.
Save ShilpiMaurya/bcc8e67435776b77531255bac38cbc06 to your computer and use it in GitHub Desktop.
//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