Answers for "build a prefix array cpp"

C++
0

build a prefix array cpp

void fillPrefixSum(int arr[], int n, int prefixSum[]) 
{ 
    prefixSum[0] = arr[0]; 
  
    // Adding present element 
    // with previous element 
    for (int i = 1; i < n; i++) 
        prefixSum[i] = prefixSum[i - 1] + arr[i]; 
}
Posted by: Guest on July-25-2020

Browse Popular Code Answers by Language