Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Maintain the next id that should be outputted.
Maintain the ids that were inserted in the stream.
Per each insert, make a loop where you check if the id that has the turn has been inserted, and if so increment the id that has the turn and continue the loop, else break.