1656. Design an Ordered Stream
On This Page
class OrderedStream:
def __init__(self, n: int):
self.data = [None] * n
self.ptr = 0
def insert(self, idKey: int, value: str) -> List[str]:
self.data[idKey - 1] = value
res = []
while self.ptr < len(self.data) and self.data[self.ptr]:
res.append(self.data[self.ptr])
self.ptr += 1
return res
# Your OrderedStream object will be instantiated and called as such:
# obj = OrderedStream(n)
# param_1 = obj.insert(idKey,value)