A player sends [start, end] stretches (minutes into the title) for everything a viewer watched, in no particular order. Rewinds mean stretches overlap. Write minutes_watched(intervals) returning the total minutes of the title they actually saw, counting any minute watched more than once only once. Stretches that just touch, such as [0, 10] and [10, 15], join up. Times can be decimals.
Example
minutes_watched([[0, 10], [5, 20], [30, 40]])
30
What this question tests
Tests merging overlapping intervals, one of the most frequently asked patterns in big tech coding rounds, here in its data form: how much of a title did someone really watch. Rewinds make the stretches overlap, so adding them up double counts.
More Python interview questions