cpp incorrect implementation of Insert Intervals