← Quiz: Interval Problems: all 10 questions
Quiz: Interval Problems · Question 6 of 10
What does this print? (code)
What does this print?
events = []
for s, e in [[1, 5], [2, 6], [4, 8], [7, 9]]:
events += [(s, 1), (e, -1)]
cur = best = 0
for t, k in sorted(events):
cur += k
best = max(best, cur)
print(best)
- A.2
- B.4
- C.3
- D.1
Answer & explanation
Correct answer: 3
At time 4, the meetings [1, 5], [2, 6] and [4, 8] are all running.
Can you get the rest right without peeking?
Take the timed Quiz: Interval Problems quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →