What is wrong in this code max subarray sum challenge

using namespace std;
int main()
{
int n,k,t;
cin>>t;
for(k=0;k<t;k++)
{
cin>>n;
int a[100000];
for(int i=0; i<n; i++)
{
cin>>a[i];
}
int cs=0,ms=0;
for(int i=0;i<n;i++)
{
cs=cs+a[i];
if(cs<0)
{
cs=0;
}
ms=max(ms,cs);
}
cout<<ms<<endl;
}
return 0;
}

Hey @sneha23
Please share your code in Coding Blocks Ide :slight_smile:

hey, that might sound weird but i am not able to find how to copy the link out there could u please check it in this way only if possible

Hey @sneha23
Its working fine on my side ,please recheck :slight_smile:

exactly thats my point i have checked it every way!!!
ok lemme try once again…if that doesnt work i will send the ss

hey it worked out
i dont know why did that happened sorry for troubling…thanx:)

1 Like

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.