GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — leetcode-4/java/836_Rectangle_Overlap.java at master · Spencerai/leetcode-4 Expand file tree/ Copy path836_Rectangle_Overlap.javaMore file actions 22 lines (21 loc) · 1 KB / Copy path836_Rectangle_Overlap.javaFile metadata and controls22 lines (21 loc) · 1 KB 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. |