Javascript Hashmap solution
Straightforward Hashmap implementation. All functions run in O(1) but memory is O(nK) where K is number of snapshots. \n\n\n/**\n * @param {number} length\n */\
Straightforward Hashmap implementation. All functions run in O(1) but memory is O(nK) where K is number of snapshots. \n\n```\n/**\n * @param {number} length\n */\nvar SnapshotArray = function(length) {\n    this.arr = []\n    this.snapCount = 0;\n    this.snapMap = new Map(); // id -> array\n};\n\n/** \n * @param {number} index \n * @param {number} val\n * @return {void}\n */\nSnapshotArray.prototype.set = function(index, val) {\n    this.arr[index] = val;\n};\n\n/**\n * @return {number}\n */\nSnapshotArray.prototype.snap = function() {\n    this.snapCount++;\n    let snap_id = this.snapCount-1;\n    let snapshot = [...this.arr] // make a copy of the snapshot\n    this.snapMap.set(snap_id, snapshot);\n    return snap_id;\n};\n\n/** \n * @param {number} index \n * @param {number} snap_id\n * @return {number}\n */\nSnapshotArray.prototype.get = function(index, snap_id) {\n    let arrAtSnapID = this.snapMap.get(snap_id);\n    return arrAtSnapID[index] === undefined ? null : arrAtSnapID[index]\n};\n\n/** \n * Your SnapshotArray object will be instantiated and called as such:\n * var obj = new SnapshotArray(length)\n * obj.set(index,val)\n * var param_2 = obj.snap()\n * var param_3 = obj.get(index,snap_id)\n */\n```
['JavaScript']