Java beats 100% with one statement. Explained
I felt so good about myself after I came up with this as my first solution. (I was initally going to loop through everything)\nWhy below works?\nIf you did merg
I felt so good about myself after I came up with this as my first solution. (I was initally going to loop through everything)\nWhy below works?\nIf you did merge time interval or detect time interval overlap problem, you should have a head start already.\nA formula that all leetcoders should remember to test for overlap:\n`firstStart < secondEnd && secondStart < firstEnd`\nThis statement returns true if 2 intervals overlap.\nUsing this concept, two rectangle overlaps iff:\n1) their x\'s overlap `(rec1[0] < rec2[2] && rec2[0] < rec1[2])`\n2) their y\'s overlap `(rec1[1] < rec2[3] && rec2[1] < rec1[3])`\n\n\n```\nclass Solution {\n    public boolean isRectangleOverlap(int[] rec1, int[] rec2) {\n        return (rec1[0] < rec2[2] && rec2[0] < rec1[2]) && \n\t\t\t\t(rec1[1] < rec2[3] && rec2[1] < rec1[3]);\n    }\n}\n```
[]