Java ArrayList solution
The main idea is that we can utilize the indices of the array list for each index to correspond to the id. \n\nIn the get() method:\n If we cannot find the id, 
The main idea is that we can utilize the indices of the array list for each index to correspond to the id. \n\nIn the get() method:\n* If we cannot find the id, it means that at this specific snapshot it was never modifed. So we either pull the last changed value for this index, or return 0 if it was never modified at all (i.e. list is empty)\n\nIn the set() method:\n* We will fill the gap between the last snap_id and the current one with the latest changed (last snap_id) and then replace the value with the given value in the method parameter for this current snap_id.\n\n\n```\nclass SnapshotArray {\n    \n    private int id;\n    private List<Integer>[] array;\n    \n    public SnapshotArray(int length) {\n        array = new List[length];\n        for(int i = 0; i < array.length; i++) array[i] = new ArrayList<>();\n        id = 0;\n    }\n    \n    public void set(int index, int val) {\n        List<Integer> list = array[index];\n        int valueRepeat = (list.isEmpty()) ? 0 : list.get(list.size()-1);\n        for(int i = list.size() - 1; i < id; i++) list.add(valueRepeat);\n        list.set(id, val);\n    }\n    \n    public int snap() {\n        return id++;\n    }\n    \n    public int get(int index, int snap_id) {\n        List<Integer> list = array[index];\n        if(list.isEmpty()) return 0;\n        if(list.size()-1 < snap_id) return list.get(list.size()-1);\n        return list.get(snap_id);\n    }\n}\n```
[]