Check my code please it is correct with test cases but showing error on submission

#include<bits/stdc++.h>

using namespace std;

int main() {
int t;
cin >> t;
while(t–){
int n;
cin >> n;
int arr[n];
for(int i=0; i<n; i++){
cin >> arr[i];
}
long long int sum = -100000000;
for(int i=0; i<n; i++){
sum+=arr[i];
if(sum<arr[i]){
sum=arr[i];
}
}
cout << sum << endl;
}
return 0;
}

hi @manas_gautam, its 2d array question you r applying directly kadane thats for 1d

refer here its a well commented code but still do a dry run yourself https://ide.codingblocks.com/s/659265

hope this helps :slight_smile:

It is a 1d array question
it is asking for t testcases and for each testcase length of array and array is provided

hi @manas_gautam let me check again

1 Like

@manas_gautam, sorry I misunderstood the question that day :sweat_smile:
here’s the updated code https://ide.codingblocks.com/s/659357 I’ve commented and corrected it

okay thanks for the help

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.