Java Solution | Only Save The Delta Changes | O(1) Lookup
\nclass SnapshotArray {\n\n    Map<Integer, Integer> pair;\n    Map<Integer, Map<Integer, Integer>> map;\n    public SnapshotArray(int length) {\n        this.p
```\nclass SnapshotArray {\n\n    Map<Integer, Integer> pair;\n    Map<Integer, Map<Integer, Integer>> map;\n    public SnapshotArray(int length) {\n        this.pair = new HashMap<Integer, Integer>();\n        this.map = new HashMap<>();\n    }\n    \n    public void set(int index, int val) {\n        this.pair.put(index, val);\n    }\n    \n    public int snap() {\n        int snapId = map.size();\n        map.put(snapId, new HashMap<Integer, Integer>(this.pair));\n        return snapId;\n    }\n    \n    public int get(int index, int snap_id) {\n        if(map.containsKey(snap_id)) {\n            return map.get(snap_id).containsKey(index) ? map.get(snap_id).get(index) : 0;\n        }\n        return -1;\n    }\n}\n\n/**\n * Your SnapshotArray object will be instantiated and called as such:\n * SnapshotArray obj = new SnapshotArray(length);\n * obj.set(index,val);\n * int param_2 = obj.snap();\n * int param_3 = obj.get(index,snap_id);\n */\n```
[]