“…A new array is created containing the ranges of the occurrence for the labels. For example, if the input array was [0, 0, 0, 1, 1, 1, 2, 2, 3, 3, 4], the output array will be [(0, 2), (3, 5), (6, 7), (8,9), (10,10)] because the 0 occurred at indexes 0 -2, etc. For simplicity, we added an additional if statement that limits the length of these ranges.…”