Fill in the next numbers code-golf array number
Given a list of integers, output a list where the \$ i \$th element of the list equals the first number in the input list which is \$ \ge i \$, until there are no such numbers.
For example, if the input is:
2 3 5 7 11
then we "expand" the sequence out to show where the gaps are:
_ 2 3 _ 5 _ 7 _ _ __ 11 # input
1 4 6 8 9 10 # gaps
Now we fill in the blanks with the next number that is in the sequence in each case:
2 2 3 5 5 7 7 11 11 11 11
1 4 6 8 9 10
This is the output.
Test cases
[1] -> [1]
[3] -> [3, 3, 3]
[1, 2, 3] -> [1, 2, 3]
[1, 3, 4, 9] -> [1, 3, 3, 4, 9, 9, 9, 9, 9]
[2, 3, 5, 7, 11] -> [2, 2, 3, 5, 5, 7, 7, 11, 11, 11, 11]
Rules
- You may assume the input list is non-empty, strictly increasing, and only contains positive integers
- You may use any standard I/O method
- Standard loopholes are forbidden
- This is code-golf, so the shortest code in bytes wins
MetaFill in the next numbers
- Better title?
- Is this a duplicate?
- Probably
- Is this clear enough?
- Any other feedback?