diff --git a/algorithms/CPlusPlus/Arrays/Kadane's-Algorithm.cpp b/algorithms/CPlusPlus/Arrays/Kadane's-Algorithm.cpp index ee05eb3d..eb839bf2 100644 --- a/algorithms/CPlusPlus/Arrays/Kadane's-Algorithm.cpp +++ b/algorithms/CPlusPlus/Arrays/Kadane's-Algorithm.cpp @@ -61,6 +61,21 @@ int max_subarray_sum_method_3(int arr[],int n) } return maxi; } +// optimized version kadane's algo with one loop +long long max_subarray_sum_method_4 (int arr[],int n) { //used for long and big values or integers + long long sum,maxi=0; //declaring variables + for (int i=0; i