Expand a Run-Length Iterator
Problem statement
A run-length encoding is an array of pairs [value,count]. The iterator would return value exactly count times before advancing to the next pair.
Return the complete finite iterator output. Pairs with count zero contribute nothing. Preserve pair order and repeated values in different pairs.
Function
expandRuns(runs: int[][]) → int[]Examples
Example 1
runs = [[1,2],[4,3]]return = [1,1,4,4,4]Value 1 appears twice and value 4 appears three times.
Example 2
runs = [[5,0],[2,1]]return = [2]The zero-count run is skipped.
Example 3
runs = []return = []An empty iterator has no output.
Constraints
0 <= runs.length <= 100000.- Each row is
[value,count]with signed integer value and0 <= count. - The total output length is at most
200000.