sample test cases are running
but showing TLE after submitting
Showing error time limited exceeded
@Piyush-Pandey-2580479718941914
- n can be upto 10^5 but you have created your arr[] of size 10^4, So your code may give runtime error. Increase size of arr[]
- values of array is upto 10^9. So when you add values, sum cann’t be stored in int . Use long long int
@Piyush-Pandey-2580479718941914
Also consider this testcase
1
3
-10 -5 -10
ans should be “-5” not 0
i have considered both issues
now it is giving wrong aNSWER
@Piyush-Pandey-2580479718941914
else part in line 19 to 23 isn’t required. Instead you have to add this condition
if(sum<0){ sum=0; }
I have updated your code, Please check it here https://ide.codingblocks.com/s/240369