Maximum subarray sum- not able to submit

arrays- target sum pairs. All the test cases are passed but it’s not getting green. when i run it, it shows the correct output but on submitting, it shows run time error.

@RIDDHI29 hey ridhi the reason for the run error is that this code needs T no of tests cases. and your code will written inside of the test cases loop and do increase the size of array.

but I’m taking the input for test cases outside only and then for each test case I’m taking the input of length of array. Can you help me with what changes I should do in my code? Also, I increased the array size.

@RIDDHI29 hey riddle the main reason for this run error is that you are using one loop for input and changing content of the array with the same loop which is wrong first take all element of array and process those element in separate loop which will remove run error and pass the evaluation.

https://ide.codingblocks.com/s/92731 Using your advice, I modified the code but it is still showing the same error even though output is right.

@RIDDHI29 hey riddhi I have modified your code.I appreciate yout effort
modified link

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.