what's the value of the intervals?
I see in your example that the first set has a length of 5 but the next one only has 2 and at the last is probably for the remaining elements, is there a pattern for this?
once you know the value of the interval all you need to do is assign the value per interval to the output array
what does missing numbers have to do with intervals?
The reason of the exercise are the missing numbers. There is nothing to do with the missing numbers, but I should create intervals from the existing numbers, beacuse of the missing numbers. If there is no missing number the whole array will be only 1 interval.