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.
We'll cover the following...
We'll cover the following...
Problem statement
In this challenge, you have to implement a SnapshotArray with the following properties:
-
initialize(length): This property initializes a data structure withlengthnumber of indexes. Initially, the value at each index is0. -
set_value(idx,val)...