To find number of events occuring at a given point affected by multiple ranges.

Problems

370. Range Addition

starts = defaultdict(int)
ends = defaultdict(int)

for s, e, inc in updates:
    starts[s] += inc
    ends[e] += inc

inc = 0
res = []
for i in range(length):
    inc += starts[i]
    res.append(inc)
    inc -= ends[i]

return res

2381. Shifting Letters II