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

Function maxSubArraySum

Dynamic Programming/Kadanes.cpp:5–14  ·  view source on GitHub ↗

This is the smallest code for kadanes algorithm

Source from the content-addressed store, hash-verified

3using namespace std;
4//This is the smallest code for kadanes algorithm
5int maxSubArraySum(int A[], int size)
6{
7 int ans = A[0];
8 int sum = A[0];
9 for(int i =1 ; i<size;i++){
10 sum = max(A[i],sum+A[i]);
11 ans = max(ans,sum);
12 }
13 return ans;
14}
15
16// Driver Code
17int main()

Callers 1

mainFunction · 0.70

Calls 1

maxFunction · 0.50

Tested by

no test coverage detected