forked from luliyucoordinate/Leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1353.py
More file actions
22 lines (19 loc) · 663 Bytes
/
Copy path1353.py
File metadata and controls
22 lines (19 loc) · 663 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
class Solution:
def maxEvents(self, events: List[List[int]]) -> int:
events.sort()
q, res, index, n = [], 0, 0, len(events)
l, r = 100000, 0
for i, j in events:
l, r = min(l, i), max(r, j)
for i in range(l, r + 1):
while index < n and events[index][0] <= i:
heapq.heappush(q, events[index][1])
index += 1
if not q and index == n:
return res
while q:
pre = heapq.heappop(q)
if i <= pre:
res += 1
break
return res