Search⌘ K
AI Features

DIY: Snapshot Array

Explore how to implement a SnapshotArray with index-based setting, snapshot capturing, and retrieving values by snapshot ID. Understand the core methods to confidently solve related coding interview challenges.

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_value(idx,val) ...