Back to problems

Key Store With Sum-Dependency Cascades

Object-Oriented Programming · Airbnb · Hard

Requirements set_value(key, value) — assign an integer value to key. set_sum(key, refs) — make key equal to the sum of the values currently associated with the keys in refs. Repeated references must be counted separately, so ["C", "C", "A"] represents 2C + A. get_value(key) — retrieve the integer represented by key. For a key created with set_sum, this must be its up-to-date calculated value. When a base key changes, the update must flow through all keys that depend on it,…

Checking your access…