Skip to content

Commit 614dbce

Browse files
committed
1942
1 parent b17fffb commit 614dbce

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Oct-11-24.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution:
2+
def smallestChair(self, times: List[List[int]], targetFriend: int) -> int:
3+
chair = [i for i in range(len(times))]
4+
depTime = []
5+
arrTime = [(i,j,id) for id,(i,j) in enumerate(times)]
6+
heapq.heapify(arrTime)
7+
heapq.heapify(chair)
8+
c = 0
9+
while True:
10+
s,e,f = heapq.heappop(arrTime)
11+
while depTime and depTime[0][0]<=s:
12+
t,tempChair = heapq.heappop(depTime)
13+
heapq.heappush(chair,tempChair)
14+
c = heapq.heappop(chair)
15+
heapq.heappush(depTime,(e,c))
16+
if f==targetFriend:
17+
return c

0 commit comments

Comments
 (0)