Algorithm · C3.ai · Medium
Implement a data structure that behaves like an array with a fixed number of slots, where every slot holds 0 when the structure is created. It must support three operations: Assign a value to the slot at a given index. Take a snapshot of the current contents; this operation returns an id identifying the snapshot. Given an index and a snapshot id, return the value that the slot at that index held at the moment that snapshot was taken. Examples Example