GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — leetcode/java/836_Rectangle_Overlap.java at master · zhimintu/leetcode

Expand file tree

/

836_Rectangle_Overlap.java

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
22 lines (21 loc) · 1 KB
/

836_Rectangle_Overlap.java

Copy path

File metadata and controls

22 lines (21 loc) · 1 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
class Solution {
/*public boolean isRectangleOverlap(int[] rec1, int[] rec2) {
// Check position
return !(rec1[2] <= rec2[0] || // left
rec1[3] <= rec2[1] || // bottom
rec1[0] >= rec2[2] || // right
rec1[1] >= rec2[3]); // top
}*/
/*public boolean isRectangleOverlap(int[] rec1, int[] rec2) {
// Check area
// https://leetcode.com/problems/rectangle-area/discuss/62149/Just-another-short-way
int left = Math.max(rec1[0], rec2[0]), right = Math.max(Math.min(rec1[2], rec2[2]), left);
int bottom = Math.max(rec1[1], rec2[1]), top = Math.max(Math.min(rec1[3], rec2[3]), bottom);
return (right - left) * (top - bottom) != 0;
}*/
public boolean isRectangleOverlap(int[] rec1, int[] rec2) {
// Check area
return (Math.min(rec1[2], rec2[2]) > Math.max(rec1[0], rec2[0]) && // width > 0
Math.min(rec1[3], rec2[3]) > Math.max(rec1[1], rec2[1])); // height > 0
}
}
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.