File tree 5 files changed +41
-0
lines changed
algorithms/RectangleOverlap
5 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -174,6 +174,7 @@ All solutions will be accepted!
174
174
| 401| [ Binary Watch] ( https://leetcode-cn.com/problems/binary-watch/description/ ) | [ java/py/js] ( ./algorithms/BinaryWatch ) | Easy|
175
175
| 482| [ License Key Formatting] ( https://leetcode-cn.com/problems/license-key-formatting/description/ ) | [ java/py/js] ( ./algorithms/LicenseKeyFormatting ) | Easy|
176
176
| 720| [ Longest Word In Dictionary] ( https://leetcode-cn.com/problems/longest-word-in-dictionary/description/ ) | [ java/py/js] ( ./algorithms/LongestWordInDictionary ) | Easy|
177
+ | 836| [ Rectangle Overlap] ( https://leetcode-cn.com/problems/rectangle-overlap/description/ ) | [ java/py/js] ( ./algorithms/RectangleOverlap ) | Easy|
177
178
178
179
# Database
179
180
| #| Title| Solution| Difficulty|
Original file line number Diff line number Diff line change
1
+ # Rectangle Overlap
2
+ This problem is easy to solve
Original file line number Diff line number Diff line change
1
+ class Solution {
2
+ public boolean isRectangleOverlap (int [] rec1 , int [] rec2 ) {
3
+ if (rec1 [0 ] >= rec2 [2 ] || rec2 [0 ] >= rec1 [2 ]) {
4
+ return false ;
5
+ } else if (rec1 [1 ] >= rec2 [3 ] || rec2 [1 ] >= rec1 [3 ]) {
6
+ return false ;
7
+ }
8
+
9
+ return true ;
10
+ }
11
+ }
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @param {number[] } rec1
3
+ * @param {number[] } rec2
4
+ * @return {boolean }
5
+ */
6
+ var isRectangleOverlap = function ( rec1 , rec2 ) {
7
+ if ( rec1 [ 0 ] >= rec2 [ 2 ] || rec2 [ 0 ] >= rec1 [ 2 ] ) {
8
+ return false
9
+ } else if ( rec1 [ 1 ] >= rec2 [ 3 ] || rec2 [ 1 ] >= rec1 [ 3 ] ) {
10
+ return false
11
+ }
12
+
13
+ return true
14
+ } ;
Original file line number Diff line number Diff line change
1
+ class Solution (object ):
2
+ def isRectangleOverlap (self , rec1 , rec2 ):
3
+ """
4
+ :type rec1: List[int]
5
+ :type rec2: List[int]
6
+ :rtype: bool
7
+ """
8
+ if rec1 [0 ] >= rec2 [2 ] or rec2 [0 ] >= rec1 [2 ]:
9
+ return False
10
+ elif rec1 [1 ] >= rec2 [3 ] or rec2 [1 ] >= rec1 [3 ]:
11
+ return False
12
+ return True
13
+
You can’t perform that action at this time.
0 commit comments