Question DSA-GRDY-0044
MediumWhat is the output of this code?
jobs = [("a", 2, 100), ("b", 1, 19), ("c", 2, 27), ("d", 1, 25), ("e", 3, 15)]
slots = [None] * 3
for name, dl, p in sorted(jobs, key=lambda j: -j[2]):
for t in range(dl - 1, -1, -1):
if slots[t] is None:
slots[t] = name
break
print(slots)
- A.
['a', 'c', 'e']
- B.
['d', 'a', 'e']
- C.
Sign up free to see the answer and a step-by-step explanation.