Moubt in maximum circular subarray

i didn’t get the code of this maximum circular subarray sum.
and i think doubt in it can’t be asked by typing . so can i ask doubt on call?
please!!!

hi shubham
please accept the request chat option. i will explain you.

1 Like

i have accepted it pls reply

i couldn’t understand this line form code given in the pdf!
max_wrap = max_wrap + kadane(a, n);
please help me with if
code given in pdf is as follows.
#include<stdio.h>
using namespace std;
// Standard Kadane’s algorithm to find maximum subarray
// sum
int kadane(int a[], int n);
// The function returns maximum circular contiguous sum
// in a[]
int maxCircularSum(int a[], int n)
{// Case 1: get the maximum sum using standard kadane’
// s algorithm
int max_kadane = kadane(a, n);
// Case 2: Now find the maximum sum that includes
// corner elements.
int max_wrap = 0, i;
for (i=0; i<n; i++)
{
max_wrap += a[i]; // Calculate array-sum
a[i] = -a[i]; // invert the array (change sign)
}
// max sum with corner elements will be:
// array-sum - (-max subarray sum of inverted array)
max_wrap = max_wrap + kadane(a, n);
// The maximum circular sum will be maximum of two sums
return (max_wrap > max_kadane)? max_wrap: max_kadane;
}
// Standard Kadane’s algorithm to find maximum subarray sum
// See https://www.geeksforgeeks.org/archives/576 for details
int kadane(int a[], int n)
{
int max_so_far = 0, max_ending_here = 0;
int i;
for (i = 0; i < n; i++)
{
max_ending_here = max_ending_here + a[i];
if (max_ending_here < 0)
max_ending_here = 0;
if (max_so_far < max_ending_here)
max_so_far = max_ending_here;
}
return max_so_far;
}
/* Driver program to test maxCircularSum() */
int main()
{
//int a[] = {10, -3, -4, 7, 6, 5, -4, -1};
//int n = sizeof(a)/sizeof(a[0]);
int t;
scanf("%d", &t);
//cin>>t;
for(int i=0;i<t;i++)
{
int n;
scanf("%d", &n);
//cin>>n;
int a[n];
for(int j=0;j<n;j++)
{
scanf("%d", &a[j]);
//cin>>a[j];
}
printf("%d \n",
maxCircularSum(a, n));
}
return 0;
}

leave it i got the code!
thanks for your time.