Simple lists solution
Intuition\n Describe your first thoughts on how to solve this problem. \nWe only save the value (and the snap_id) on \'Set\'.\nThen for \'Get\' we search the li
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe only save the value (and the snap_id) on \'Set\'.\nThen for \'Get\' we search the list in reverse order to find the right value for the given snap_id.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\nHaving:\nn - The length of the array.\nm - The number of ```Set()``` calls.\n- Time complexity: ```Get()```: O(m).\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n + m).\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\npublic class SnapshotArray {\n    int m_snap_id;\n    List<(int snap_id, int value)>[] values;\n\n    public SnapshotArray(int length) {\n        m_snap_id = 0;\n        values = new List<(int snap_id, int value)>[length];\n        for (int i = 0; i < length; i++) {\n            values[i] = new List<(int snap_id, int value)>();\n        }\n    }\n    \n    public void Set(int index, int val) {\n        values[index].Add((m_snap_id, val));\n    }\n    \n    public int Snap() {\n        return m_snap_id++;\n    }\n    \n    public int Get(int index, int snap_id) {\n        var list = values[index];\n        for (int i = list.Count - 1; i >= 0; i--) {\n            if (list[i].snap_id <= snap_id) {\n                return list[i].value;\n            }\n        }\n        // Return the initial value.\n        return 0;\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```
['C#']