MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / prefix_sum

Function prefix_sum

CPP/array-2d/prefix_sum.cpp:3–19  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1#include<bits/stdc++.h>
2using namespace std;
3int prefix_sum(int arr[],int n){
4 int largest_sum;
5 for (int i = 0; i < n; ++i)
6 {
7 for (int j = i; j < n; ++j)
8 {
9 int super_sum=0;
10 for (int k = i; k <= j; ++k)
11 {
12 super_sum+=arr[k];
13 }
14 largest_sum= max(largest_sum,super_sum);
15
16 }
17 }
18 return largest_sum;
19}ii
20void initial(){
21 #ifndef ONLINE_JUDGE
22 freopen("input.txt", "r", stdin);

Callers 1

mainFunction · 0.70

Calls 1

maxFunction · 0.70

Tested by

no test coverage detected