Skip to content

Commit ea407ef

Browse files
committed
Meeting Rooms
1 parent 3078844 commit ea407ef

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Meeting_Rooms.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Given an array of meeting time intervals consisting of start and end times
2+
# [[s1,e1],[s2,e2],...] (si < ei), determine if a person could attend all meetings.
3+
#
4+
# Example 1:
5+
#
6+
# Input: [[0,30],[5,10],[15,20]]
7+
# Output: false
8+
# Example 2:
9+
#
10+
# Input: [[7,10],[2,4]]
11+
# Output: true
12+
13+
14+
class Solution:
15+
def canAttendMeetings(self, intervals):
16+
17+
intervals.sort(key=lambda x: [x[0]])
18+
19+
for i in range(len(intervals) - 1):
20+
if intervals[i][1] > intervals[i + 1][0]:
21+
return False
22+
23+
return True

0 commit comments

Comments
 (0)