Sum of two arrays (doubt)


not executing ,. please tell me the error in it

The error is small you have used i++ in a loop where it must be i–. But further the method you are using is wrong as for array of length larger than 6 your int will not be able to store value as int datatype can store integer to a range of 10 raised to the power of 6 and hence your code will give wrong answer. Check my changes and comment in your code and then think of a way to solve the error of range.

it is still giving two wrong test cases


and for the range part i have used long at some places , please check what is wrong in it?

Long takes value till the range of approx 10 raised to power of 20 but in question the constrain given are till 10 raised to the power 1000.
Think of some other alternative different approach to deal with that.As a hint , try adding the index of array from last along with the carry from the previous sum and continue it till the first element of array.

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.