Search⌘ K

DIY: Snapshot Array

Explore how to build and manipulate a SnapshotArray data structure in Ruby, implementing initialization, setting values, taking snapshots, and retrieving historical values. Understand the logic needed to solve this common coding interview problem to enhance your problem-solving skills.

Problem statement

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

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

  • set_value(idx,val) ...