Timeline Lazy Minimum Problem

Timeline Lazy Minimum Problem — ExecCode Hard DSA Practice

Solve the Timeline Lazy Minimum problem on ExecCode. Free online hard DSA practice in Two Pointers. Write and run code in Java, C++, Python — no signup required to run.

Problem description

n counters start at 0. You add x to every index in [l, r], or you ask for the minimum in [l, r]. A segment tree with lazy propagation handles both in logarithmic time per operation. Type 0 l r x range-adds. Type 1 l r appends the minimum. Indices are 0-based and inclusive. You are given: n — length queries — operations Return minima from type-1 queries. After several adds, the min is the smallest current counter in that slice.

Examples

Input {'n': 3, 'queries': [[0, 0, 1, 4], [1, 0, 2], [0, 2, 2, 1], [1, 0, 2]]}; Output [0, 1]. Input {'n': 1, 'queries': [[1, 0, 0]]}; Output [0]. Input {'n': 2, 'queries': [[0, 0, 1, -5], [1, 0, 1]]}; Output [-5]

Constraints

Array starts at 0 l <= r

Practice Timeline Lazy Minimum free on ExecCode. Browse DSA problems, topic map, and placement guides.