Maximum subarray sum
You have not mentioned what exactly is your doubt.
Also check the constraints
Constraints
1 <= N <= 100000
1 <= t <= 20
-100000000 <= A[i] <= 100000000
But you have restricted the size of your array to 1000. So this may case runtime error on submission.
Increase array size to 100000
my code is not giving the right answer due to input can you please help me on how to use test cases in the code . how to input them
You did not take the input for test cases.
First take input the number of testcases t. It is the number of time your code’s logic will run.
Handle test case input like this:
int t;
cin>>t;
while(t–)
{
//Take input N and the array
//Rest part of your code(The logic)
}
This loop will run separately for each test case.
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.