1834 Single-Threaded CPU
class Solution:
def getOrder(self, tasks: List[List[int]]) -> List[int]:
for i, task in enumerate(tasks):
task.append(i)
tasks.sort()
ans = []
q = []
n = len(tasks)
i = t = 0
while q or i < n:
if not q:
t = max(t, tasks[i][0])
while i < n and tasks[i][0] <= t:
heappush(q, (tasks[i][1], tasks[i][2]))
i += 1
pt, j = heappop(q)
ans.append(j)
t += pt
return ans
621 Task Scheduler
630 Course Schedule III
1029 Two City Scheduling
1229 Meeting Scheduler
2365 Task Scheduler II
1335 Minimum Difficulty of a Job Schedule
1462 Course Schedule IV
207 Course Schedule
210 Course Schedule II