HardPro challengeJavaScriptTypeScript

Virtual List Window

ReactPerformanceVirtualization

Given total items, item height, viewport height, and scroll offset, return
the indices that should render.

solve(total, itemHeight, viewportHeight, scrollTop, overscan = 0) returns
{ start, end } (inclusive).

Sample tests

Test #1Scrolled
Input: [100,30,300,90,0]
Output: {"end":13,"start":3}
Test #2With overscan
Input: [100,30,300,0,2]
Output: {"end":14,"start":0}
Test #3Fewer items than viewport
Input: [5,30,300,0,0]
Output: {"end":4,"start":0}
Test #4Deep scroll
Input: [1000,50,500,5000,0]
Output: {"end":110,"start":100}
Test #5At top, 10 visible
Input: [100,30,300,0,0]
Output: {"end":10,"start":0}