Wrong answer for sum of 2 arrays
Hey @lakshit
You’re following the wrong approach
for the test case:
4
1 0 2 9
5
3 4 5 6 7
Your code yields answer as:
3 5 5 8 16
while the correct answer is:
3, 5, 5, 9, 6, END
Let me tell you how the addition is being done.
when we start adding from the right, 9+7 = 16, the last element of the answer becomes 6 and 1 becomes a carry for the left addition, so when 2 and 6 are added, the next element of the answer becomes 2+6+1 = 9, because of the carry.
So you need to correct your approach of the code by dealing with carry at every step.