Back to problems

Lazy Array (Delayed Evaluation Array)

Object-Oriented Programming · Databricks · Easy

You are given a length-n abstract data structure named LazyArray. Its elements may begin with supplied values or, when no values are supplied, with zeros. Updates should be stored lazily and applied only when a value is requested. Design and implement LazyArray with at least these operations: range_add(l, r, delta): increase every element whose index lies in the inclusive range [l, r] by delta. get(i): return the value at index i after accounting for every update issued so…

Checking your access…