DIY: Snapshot Array

Solve the interview question "Snapshot Array" in this lesson.

Problem statement

In this challenge, you have to implement a SnapshotArray with the following properties:

  • SnapshotArray(length): This property initializes a data structure with length number of indexes. Initially, the value at each index is 0.

  • set(idx, val) ...