File tree 4 files changed +48
-4
lines changed
solution/0200-0299/0252.Meeting Rooms
4 files changed +48
-4
lines changed Original file line number Diff line number Diff line change 30
30
<!-- 这里可写当前语言的特殊实现逻辑 -->
31
31
32
32
``` python
33
-
33
+ class Solution :
34
+ def canAttendMeetings (self , intervals : List[List[int ]]) -> bool :
35
+ intervals.sort(key = lambda x : x[0 ])
36
+ for i in range (len (intervals) - 1 ):
37
+ if intervals[i][1 ] > intervals[i + 1 ][0 ]:
38
+ return False
39
+ return True
34
40
```
35
41
36
42
### ** Java**
37
43
38
44
<!-- 这里可写当前语言的特殊实现逻辑 -->
39
45
40
46
``` java
41
-
47
+ class Solution {
48
+ public boolean canAttendMeetings (int [][] intervals ) {
49
+ Arrays . sort(intervals, Comparator . comparingInt(a - > a[0 ]));
50
+ for (int i = 0 , n = intervals. length; i < n - 1 ; ++ i) {
51
+ if (intervals[i][1 ] > intervals[i + 1 ][0 ]) return false ;
52
+ }
53
+ return true ;
54
+ }
55
+ }
42
56
```
43
57
44
58
### ** ...**
Original file line number Diff line number Diff line change 29
29
### ** Python3**
30
30
31
31
``` python
32
-
32
+ class Solution :
33
+ def canAttendMeetings (self , intervals : List[List[int ]]) -> bool :
34
+ intervals.sort(key = lambda x : x[0 ])
35
+ for i in range (len (intervals) - 1 ):
36
+ if intervals[i][1 ] > intervals[i + 1 ][0 ]:
37
+ return False
38
+ return True
33
39
```
34
40
35
41
### ** Java**
36
42
37
43
``` java
38
-
44
+ class Solution {
45
+ public boolean canAttendMeetings (int [][] intervals ) {
46
+ Arrays . sort(intervals, Comparator . comparingInt(a - > a[0 ]));
47
+ for (int i = 0 , n = intervals. length; i < n - 1 ; ++ i) {
48
+ if (intervals[i][1 ] > intervals[i + 1 ][0 ]) return false ;
49
+ }
50
+ return true ;
51
+ }
52
+ }
39
53
```
40
54
41
55
### ** ...**
Original file line number Diff line number Diff line change
1
+ class Solution {
2
+ public boolean canAttendMeetings (int [][] intervals ) {
3
+ Arrays .sort (intervals , Comparator .comparingInt (a -> a [0 ]));
4
+ for (int i = 0 , n = intervals .length ; i < n - 1 ; ++i ) {
5
+ if (intervals [i ][1 ] > intervals [i + 1 ][0 ]) return false ;
6
+ }
7
+ return true ;
8
+ }
9
+ }
Original file line number Diff line number Diff line change
1
+ class Solution :
2
+ def canAttendMeetings (self , intervals : List [List [int ]]) -> bool :
3
+ intervals .sort (key = lambda x : x [0 ])
4
+ for i in range (len (intervals ) - 1 ):
5
+ if intervals [i ][1 ] > intervals [i + 1 ][0 ]:
6
+ return False
7
+ return True
You can’t perform that action at this time.
0 commit comments