HardPro challengeJavaScriptTypeScript

Lazy Component Loader

ReactLazyAsync

Implement lazy(loader): a function that defers loading until first call.
Subsequent calls reuse the cached promise (no re-fetch).

solve(scenarios) returns the number of times the loader was called.

Sample tests

Test #13 calls, 1 load
Input: [3]
Output: 1
Test #2Single call
Input: [1]
Output: 1
Test #310 calls, still 1 load
Input: [10]
Output: 1
Test #4Never called
Input: [0]
Output: 0
Test #5100 calls, 1 load
Input: [100]
Output: 1