[Java] O(1) snap O(logN) get/set using TreeMap
\nclass SnapshotArray {\n    \n    List<TreeMap<Integer, Integer>> arr;\n    int currId = 0;\n\n    public SnapshotArray(int length) {\n        arr = new ArrayL
```\nclass SnapshotArray {\n    \n    List<TreeMap<Integer, Integer>> arr;\n    int currId = 0;\n\n    public SnapshotArray(int length) {\n        arr = new ArrayList();\n        \n        for (int i = 0; i < length; i++) {\n            arr.add(i, new TreeMap<Integer, Integer>());\n            arr.get(i).put(0, 0);\n        }\n    }\n    \n    public void set(int index, int val) {\n        arr.get(index).put(currId, val);\n    }\n    \n    public int snap() {\n        return currId++;\n    }\n    \n    public int get(int index, int snap_id) {\n        return arr.get(index).floorEntry(snap_id).getValue();\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```
[]