Code RoomBatch scroll repaints
EasyPrep Room Coding #4821

Batch scroll repaints

CodingAlgorithms & data structuresEntry–Mid~17 min

A virtualised feed repaints only once scrolling settles, because rebuilding the window on every scroll event burns frames. Each event restarts a quiet timer set to quiet_ms, and the repaint happens when that timer expires. So a long drag never starves the paint, a second rule caps the wait: a repaint also happens once max_wait_ms has passed since the first event of the current burst, whichever comes first. A repaint ends the burst, and the next event opens a new one. event_ms holds the event timestamps in milliseconds, in non-decreasing order, and the same millisecond may appear twice. An event landing exactly on a pending repaint time counts as arriving just after it, so that repaint happens and the event opens the next burst. Return the repaint timestamps in increasing order, and an empty list when no event arrives.

Implement
scroll_repaint_times(event_ms: list[int], quiet_ms: int, max_wait_ms: int) → list[int]
Examples
in[[0,40,90,400],100,1000]out[190,500]
in[[0,50,100,150,200],100,120]out[120,270]
What a strong answer looks like

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:00 of about 17 min
InputExpectedGot
[[0,40,90,400],100,1000][190,500]not run yetsample
[[0,50,100,150,200],100,120][120,270]not run yetsample