HardPro challengePythonJavaScriptTypeScript
Async Iterator Buffer
BackendAsyncIterators
solve(items, batchSize) consumes an async iterator over items (one per
microtask) and yields batches of batchSize (final batch may be smaller).
Return an array of batches.
Sample tests
Test #15 items, batch 2
Input: [[1,2,3,4,5],2]
Output: [[1,2],[3,4],[5]]
Test #2Even split
Input: [[1,2,3,4],2]
Output: [[1,2],[3,4]]
Test #3Empty source
Input: [[],3]
Output: []
Test #4Single item
Input: [[1],5]
Output: [[1]]
Test #5Three batches
Input: [[1,2,3,4,5,6,7],3]
Output: [[1,2,3],[4,5,6],[7]]