Object-Oriented Programming · Bloomberg · Easy
Create a data structure named OrderedStream that accepts n distinct (id, value) pairs, with every id belonging to the range [1, n]. The structure keeps a pointer ptr, initially set to 1. Whenever (id, value) is inserted, check whether the ids beginning at ptr now form an uninterrupted sequence—ptr, ptr+1, ..., k. If they do, return their associated values in id order and advance ptr to k+1. If the sequence is incomplete, return an empty list. Implement: OrderedStream(n)…
Checking your access…