| 2 | using namespace std; |
| 3 | |
| 4 | int main() { |
| 5 | int t; |
| 6 | cin>>t; //no. of testcases |
| 7 | while(t!=0) |
| 8 | { |
| 9 | int n; |
| 10 | cin>>n; //enter size of array |
| 11 | int i, e=0, f=INT_MIN, arr[n]; |
| 12 | for(i=0; i<n; i++) |
| 13 | cin>>arr[i]; //take array input |
| 14 | for(i=0; i<n; i++) |
| 15 | { |
| 16 | e=e+arr[i]; //to get maximum contiguous sum of array |
| 17 | if(f<e) |
| 18 | f=e; //updating f with maximum possible sum value |
| 19 | if(e<0) //if sum (e) happens to be negative then reintialize sum (e) = 0 |
| 20 | e=0; |
| 21 | } |
| 22 | cout<<f<<endl; |
| 23 | t--; |
| 24 | |
| 25 | } |
| 26 | return 0; |
| 27 | } |
nothing calls this directly
no outgoing calls
no test coverage detected