Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

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]; 
} 
 
PREVIOUS NEXT
Tagged: #build #prefix #array #cpp
ADD COMMENT
Topic
Name
8+3 =