#include
using namespace std;
int maxSum(int arr[],int n)
{
int maxsum;
maxsum=0;
for(int i=0;i<n;i++)
{
maxsum=maxsum+arr[i];
if(maxsum<0)
maxsum=0;
}
return maxsum;
}
int main() {
int t,n,arr[1000000];
cin>>t;
do
{
cin>>n;
for(int i=0;i<n;i++)
cin>>arr[i];
cout<<maxSum(arr,n)<<endl;
t--;
}while(t>0);
return 0;
}
above is my code. it is working fine with inputs but failing in test cases. whats wrong int his code;