Python solution with a hint before the solution.
Approach\n Describe your approach to solving the problem. \nIf you don\'t want to go through my code, I suggest you to watch the example video and observe the "
# Approach\n<!-- Describe your approach to solving the problem. -->\nIf you don\'t want to go through my code, I suggest you to watch the example video and observe the "ptr" and how it is incrementing and returning things based on the ptr value.\n\n# Code\n```\nclass OrderedStream:\n\n    def __init__(self, n: int):\n        self.arr = [""] * n\n        self.ptr = 0\n\n    def insert(self, idKey: int, value: str) -> List[str]:\n        self.arr[idKey-1] = value\n        res = []\n        if self.ptr == idKey - 1:\n            while self.ptr < len(self.arr) and self.arr[self.ptr] != "":\n                print(self.ptr)\n                res.append(self.arr[self.ptr])\n                self.ptr += 1\n\n        return res\n\n\n\n# Your OrderedStream object will be instantiated and called as such:\n# obj = OrderedStream(n)\n# param_1 = obj.insert(idKey,value)\n```
['Python3']