Implement LazyArray with Deferred Function Execution
Asked at Databricks · Coding Questions · Difficulty: Medium · Last asked Jun 9, 2026
Data-processing frameworks treat operations such as `map` and `filter` as lazy: calling them only records what should happen, and nothing is computed until a result is actually requested. Build a small class `LazyArray` that wraps a sequence and behaves this way. Chained transformations are recorded, and they run only when an action (`evaluate` or `indexOf`) is called. An action that needs only part of the result, such as `indexOf`, must stop as soon as it has its answer.
Loading the problem…