educative.io

Educative

Prefix Sum Problem : A Concurrent Approach

Hi there,

Can someone please help me to understand the prefix sum problem (a concurrent approach) as I cannot understand the flow based on the diagram?

Thank you.

Hi @seindy!

Hope you are doing well. Let’s talk about prefix sum problem. The prefix sum at some position is the sum of all elements from the beginning of the array to that position.

In that way, we can find the total sum up to a certain point by checking the prefix sum array’s value. We don’t need to go through each time to know the value between two positions in the array with a prefix sum array. We can be efficient with our code to calculate from the values in the prefix sum array.

Regards,