this is my code and i am getting wrong answers for the negative values for eg -2 -2 -2 -10
the correct answer is -10
but i am getting 0
this is my code and i am getting wrong answers for the negative values for eg -2 -2 -2 -10
the correct answer is -10
but i am getting 0
hello @shivamgoel150
it is not working because in input u have given negative number.
for negative number while loop will never run hence u will get incorrect result.
use this code only on non negative number
the code in video lecture is also not working for negative value, please tell me how to handle negative values in my code
yeah it will not work becuase we have assumed that all elements are non negative.
so use this logic only if all numbers are non negative.