Javascript solution using array - 184 ms
\nvar OrderedStream = function(n) {\n    this.arr = new Array(n);\n    this.index = 0;\n};\n\nOrderedStream.prototype.insert = function(id, value) {\n    this.a
```\nvar OrderedStream = function(n) {\n    this.arr = new Array(n);\n    this.index = 0;\n};\n\nOrderedStream.prototype.insert = function(id, value) {\n    this.arr[id - 1] = value;\n    const result = [];\n    while (this.arr[this.index]) {\n        result.push(this.arr[this.index++]);\n    }\n    return result;\n};\n```
[]