code for max circular sum using kadane’s algorithm and rotating subarray by brute force in the loop…
#include
using namespace std;
int main() {
int t;
cin>>t;
for(int i=0;i<t;i++){int n;
cin>>n;
int a[n];
int curr=0;
int max=0;
for(int j=0;j<n;j++){
for(int k=0;k<n-1;k++)
{ int num=a[n-1]; //circlar rotation of array
a[k+1]=a[k];
a[0]=num;
curr=0;
for(int h=0;h<n;h++) //Kedane's Algo
{curr+=a[h];
if(curr<0)
curr=0;
if(curr>max)
max=curr;
}
}
}
cout<<max<<endl;
}
return 0;
}
Why is maximum a garbage value???