You have sorted intervals arriving one at a time. For each arrival, you decide: does it extend the last bar, or start a new one?
Build the merged result yourself.
Each interval arrives as a ghost. Predict the action before it happens.