Recycled table rows

Write codeEasy15 minMeta style

Your task

A virtualised table recycles row components as the user scrolls, and you are measuring how much work that costs. Every row is the same pixel height, so row i covers the band starting at i times that height and ending just before the next multiple. The table holds total_rows rows and the window shows viewport pixels at once. At a given scroll offset the table keeps exactly the rows whose band overlaps the visible band, limited to the rows that exist. You receive the scroll offsets the user produced, in time order. For each offset report how many of its rows were not present at the offset before it, counting every row for the first offset. Offsets are never negative, and both the row height and the viewport are at least 1. Return one count per offset, in the same order.

Examples

row_mount_churn(row_height: int, viewport: int, total_rows: int, offsets: list[int]) -> list[int]
Example 1
Inputrow_mount_churn(50, 200, 100, [0, 50, 400])
Output[4, 1, 4]
Example 2
Inputrow_mount_churn(40, 100, 10, [0, 0, 20])
Output[3, 0, 0]
Example 3
Inputrow_mount_churn(30, 90, 5, [200])
Output[0]