[Python3] simple solution
\n\nclass OrderedStream:\n\n    def __init__(self, n: int):\n        self.data = [None]*n\n        self.ptr = 0 # 0-indexed \n\n    def insert(self, id: int, va
\n```\nclass OrderedStream:\n\n    def __init__(self, n: int):\n        self.data = [None]*n\n        self.ptr = 0 # 0-indexed \n\n    def insert(self, id: int, value: str) -> List[str]:\n        id -= 1 # 0-indexed \n        self.data[id] = value \n        if id > self.ptr: return [] # not reaching ptr \n        \n        while self.ptr < len(self.data) and self.data[self.ptr]: self.ptr += 1 # update self.ptr \n        return self.data[id:self.ptr]\n```
['Python3']