Question DSA-GRDY-0045
MediumWhat is the output of this code?
iv = [(1, 3), (2, 6), (8, 10), (9, 12), (15, 18)]
out = []
for s, e in sorted(iv):
if out and s <= out[-1][1]:
out[-1][1] = max(out[-1][1], e)
else:
out.append([s, e])
print(out)
- A.
[[1, 3], [2, 6], [8, 12], [15, 18]]
- B.
[[1, 12], [15, 18]]
- C.
Sign up free to see the answer and a step-by-step explanation.