Question DSA-GRDY-0041
MediumWhat is the output of this code?
acts = [(1, 4), (3, 5), (0, 6), (5, 7), (3, 9), (5, 9), (6, 10), (8, 11), (8, 12), (2, 14), (12, 16)]
acts.sort(key=lambda a: a[1])
end, chosen = -1, []
for s, f in acts:
if s >= end:
chosen.append((s, f)); end = f
print(len(chosen), chosen[-1])
- A.
4 (8, 12)
- B.
4 (12, 16)
- C.
Sign up free to see the answer and a step-by-step explanation.