Sustained faults across spans
A motor controller reports a fault word once per tick, bit f standing for fault f, and faults are numbered 0 to 29. The console only trusts a fault it has watched hold, so it calls a fault sustained over a stretch of ticks when that fault is active in every single tick of the stretch. frames holds the words in tick order and span gives how many consecutive ticks a stretch covers, always at least one. Return one word per stretch, in the order the stretches begin, holding exactly the faults sustained across that stretch. frames can run to a hundred thousand words and span can be almost as long, so rebuilding a stretch from scratch is too slow. Return an empty list when span is longer than the run of frames.
sustained_fault_masks(frames: list[int], span: int) → list[int][[7,6,14],2]out[6,6][[1,2,4],1]out[1,2,4][[5,5,5,1],3]out[5,1]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.
[[7,6,14],2][6,6]not run yetsample[[1,2,4],1][1,2,4]not run yetsample[[5,5,5,1],3][5,1]not run yetsample