Maximum circular sun, I guess I'm missing something, please tell me

#include
#include<limits.h>
using namespace std;
int reverkadene(int b[],int s)
{
for(int i=0;i<s;i++)
{
b[i]=-1*b[i];
}
int maxsf=b[0];
int maxhere=0;
for(int i=0;i<s;i++)
{
maxhere+=b[i];
if(maxhere<0)
maxhere=0;
maxsf=max(maxsf,maxhere);
}
return maxsf;

}
int kadane( int arr[],int N)
{ bool f=true;
for(int i=0;i<N;i++)
{
if(arr[i]>=0)
f=false;
}
int mini=INT_MAX;
int sum=0;
for(int i=0;i<N;i++)
{
sum+=arr[i];
mini=min(mini,arr[i]);
}
if(f==true)
return mini;
else
return sum+ reverkadene(arr,N);
}

int main() {
int t;
cin>>t;
while(t–)
{
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
}
cout<<kadane(a,n)<<endl;
}
return 0;
}

hello @ganesh2512

pls save ur code at cb ide and share its link with me

I have enabled collaborate mode, can you see it?

u need to consider both the cases.

a) circular and non circular, u r only considering one of them at a time

b)use simple kadane to find max sum in linear array say u get ans1,
also find max sum by flipping the sign say u get ans2 then print max among these two.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.