A quick refresher on segment trees
A segment tree is a data structure that allows answering range queries like the
sum of subarray a[[l...r] or the minimum element in such a range in O(log n).
The segment trees require a linear amount of memory and modify one