Union of intervals length
Your task
A smart plug logs every session a space heater was switched on as [start, end] minute pairs, occupying the half-open span [start, end). Several sensors report independently, so sessions may overlap or even duplicate. Return the total number of minutes the heater was actually on. Example: [[0,30],[20,50],[70,80]] gives 60.
Examples
total_on_minutes(sessions: list[list[int]]) -> intExample 1
Input
total_on_minutes([[0, 30], [20, 50], [70, 80]])Output
60