Similar Problem to Maximum Circular Subarray Sum

I wrote the solution to Maximum Circular Subarray Sum

#include
#include
using namespace std;

int main() {
//test cases
int t;
cin>>t;
while(t–){
int n;
cin>>n;
int a[n],currentSum1=0,currentSum2=0,k1=0,k2=0;
for(int i=0;i<n;i++){
cin>>a[i];
currentSum1 = currentSum1 + a[i];
currentSum2 = currentSum2 + (-a[i]);
if(currentSum1<=0){
currentSum1 = 0;
}
if(currentSum1>=k1){
k1 = currentSum1;
}
if(currentSum2<=0){
currentSum2 = 0;
}
if(currentSum2>=k2){
k2 = currentSum2;
}
}
k2 = currentSum1 + k2;
//cout<<k1<<endl;
//cout<<k2<<endl;
cout<<max(k1,k2)<<endl;
}
return 0;
}

I am getting correct answer for the sample input given in the pdf.
I wanted to ask whether this problem is similar to this problem or not
https://hack.codingblocks.com/app/practice/2/p/1288

If it is similar, for the sample input given on this link it is giving me answer as 23 which must be 22.
Please help.

@rahul.maheshmaheshwari yeah this problem is similar to the problem you’re trying to solve their is a pdf in the course that cover the implementation part.

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.