Prefix Sum (Pre Sum) in Competitive Programming
Let’s go deep into Prefix Sum (Pre Sum) from a competitive programming perspective.This is one of the fundamental techniques you’ll repeatedly use in array, string, DP, and number theory problems. What is Prefix Sum? For an array arr[0..n-1], the prefix sum array pre[i] is defined as: That is, the cumulative sum up to index i. … Read more