Paint alert timeline
A monitoring console paints one incident timeline for the whole fleet. Alert i is raised at starts[i] and clears at ends[i], covering every minute from starts[i] up to but not including ends[i], and carries a severity levels[i] between 1 and level_count. Where several alerts overlap, the console paints only the highest severity present, so a milder alert underneath contributes nothing. The alerts arrive in no particular order, an alert with equal bounds covers nothing, and minute stamps are counted from a fixed epoch so they can be negative. Timestamps reach a billion either way, so painting the timeline minute by minute is out. Return a list of length level_count where position j holds the count of minutes painted at severity j plus 1. Minutes carrying no alert are painted at no severity and belong nowhere.
top_severity_minutes(starts: list[int], ends: list[int], levels: list[int], level_count: int) → list[int][[0,10,30],[20,40,35],[1,2,3],3]out[10,25,5][[0,5,10],[5,10,15],[3,1,2],3]out[5,5,5][[0,0],[10,10],[1,3],3]out[0,0,10]State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
[[0,10,30],[20,40,35],[1,2,3],3][10,25,5]not run yetsample[[0,5,10],[5,10,15],[3,1,2],3][5,5,5]not run yetsample[[0,0],[10,10],[1,3],3][0,0,10]not run yetsample