JavaScript Simple Array Solution - 98% Faster, 27% Less Memory
I didn\'t use a hash table, I just initialized an array with a pointer and when the pointer had data I push it into a result array and returned the result array
I didn\'t use a hash table, I just initialized an array with a pointer and when the pointer had data I push it into a result array and returned the result array. See below:\n```\n/**\n * @param {number} n\n */\nvar OrderedStream = function(n) {\n  // initialize array\n  this.arr = [];\n  // start pointer at index of 0\n  this.p = 0;\n  //set array to have length of n\n  this.arr.length = n;\n};\n\n/** \n * @param {number} idKey \n * @param {string} value\n * @return {string[]}\n */\nOrderedStream.prototype.insert = function(idKey, value) {\n  // push the value into array at index of idKey\n  this.arr[idKey - 1] = value;\n  // initialize result array\n  let result = [];\n  \n  // while the pointer has a value, push that value into the result array and advance the pointer\n  while (this.arr[this.p]) {\n    result.push(this.arr[this.p]);\n    this.p++;\n  }\n  // return the result array which will either be empty if the pointer was null, or will have the chunks pushed into it\n  return result;\n};\n\n/** \n * Your OrderedStream object will be instantiated and called as such:\n * var obj = new OrderedStream(n)\n * var param_1 = obj.insert(idKey,value)\n */\n ```
['JavaScript']