Solved! Leetcode 1146. Snapshot Array

source: https://leetcode.com/problems/summary-ranges/description/ Snapshot Array Table of ContentsSnapshot ArrayDescriptionExample 1:Constraints:Solution Description Implement a SnapshotArray that supports the following interface: SnapshotArray(int length) initializes an array-like data structure with the given length. Initially, each element equals 0. void set(index, val) sets the element at the given index to be equal to val. int snap() takes a snapshot of ...

TreeMap

The TreeMap class implements the Map interface by using a tree. A TreeMap provides an efficient means of storing key/value pairs in sorted order, and allows rapid retrieval. You should note that, unlike a hash map, a tree map guarantees that its elements will be sorted in ascending key order. The TreeMap class supports four ...