From 2846c38257e26460a0a9c7c4bdd374956577a4f5 Mon Sep 17 00:00:00 2001 From: AdithyakrishnaV Date: Thu, 23 Sep 2021 13:43:03 +0530 Subject: [PATCH] Kandane's algorithum --- Kandane's_algorithum.cpp | 44 ++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/Kandane's_algorithum.cpp b/Kandane's_algorithum.cpp index 8fe28b4..b3eeee4 100644 --- a/Kandane's_algorithum.cpp +++ b/Kandane's_algorithum.cpp @@ -1,35 +1,35 @@ //Kandane's algorithum -// #include -// using namespace std; +#include +using namespace std; -// int main(){ -// int n; -// cin>>n; +int main(){ + int n; + cin>>n; -// int a[n]; + int a[n]; -// for(int i=0; i>a[i]; -// } + for(int i=0; i>a[i]; + } -// int max_sum = INT_MIN, current_sum=0; + int max_sum = INT_MIN, current_sum=0; -// for(int i=0; i max_sum){ -// max_sum = current_sum; -// } -// if(current_sum < 0){ -// current_sum = 0; -// } + if(current_sum > max_sum){ + max_sum = current_sum; + } + if(current_sum < 0){ + current_sum = 0; + } -// } + } -// cout<