diff --git a/Algorithms/Kadane.c b/Algorithms/Kadane.c new file mode 100644 index 0000000..6cce351 --- /dev/null +++ b/Algorithms/Kadane.c @@ -0,0 +1,47 @@ +/* +* CODE SUBMITTED BY- SUBHAM SAHU +* GITHUB URL - https://github.com/subhamx +* LINKED URL - https://www.linkedin.com/in/subhamX/ +* +*/ + + +/* + +INPUT FORMAT - + SIZE OF ARRAY + ARRAY ELEMENTS + +OUTPUT FORMAT - + MAXIMUM SUM OF SUBARRAY + +*/ + +#include +#include + +int main(){ + int n, temp; + scanf("%d", &n); + int A[n]; + for(int i=0; ians){ + ans=temp; + } + if(temp<0){ + temp=0; + } + } + printf("%d\n", ans); +} + +/* +ANALYSIS - + This Algorithm returns the maximum sum in O(n). +*/