Algorithmic Gems — Accumulation
"Whenever you find yourself dealing with ranges, think about storing data in cumulative form."
Read more about "Accumulation and Prefix Sums" here. Would love to hear any feedback.