My java solution without treemap 98% faster
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass SnapshotArray {\n    List<Info>[] arr;\n    int snap = 0;\n    public SnapshotArray(int length) {\n        arr = new ArrayList[length];\n    }\n    \n    public void set(int index, int val) {\n        if(arr[index] == null){\n            arr[index] = new ArrayList<>();\n        }\n        int size = arr[index].size();\n        if(size == 0){\n            arr[index].add(new Info(val, snap));\n        }else{\n            if(arr[index].get(size - 1).snap == snap){\n                arr[index].get(size - 1).val = val;\n            }else{\n                arr[index].add(new Info(val, snap));\n            }\n        }\n    }\n    \n    public int snap() {\n        return snap++;\n    }\n    \n    public int get(int index, int snap_id) {\n        if(arr[index] == null || arr[index].size() == 0){\n            return 0;\n        }\n        return bs(0, arr[index].size() - 1, index, arr, snap_id);\n    }\n\n    public int bs(int low, int high, int idx, List<Info>[] arr, int target){\n\n        while(low <= high){\n            int mid = low + (high - low) / 2;\n            if(arr[idx].get(mid).snap == target){\n                return arr[idx].get(mid).val;\n            }else if(arr[idx].get(mid).snap < target){\n                low = mid + 1;\n            }else{\n                high = mid - 1;\n            }\n        }\n        if(high < 0){\n           return 0;\n        }\n        return arr[idx].get(high).val;\n    }\n\n    public class Info{\n        int val;\n        int snap;\n\n        public Info(int val, int snap){\n            this.val = val;\n            this.snap = snap;\n        }\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```
['Java']