Problem in test cases

4

1 0 2 9

5

3 4 5 6 7

O/p is correct

3 , 5, 5, 9, 6, END

but if reverse is passed

for eg

5

3 4 5 6 7

4

1 0 2 9

the o/p is wrong

why this is happening my code is https://ide.codingblocks.com/s/207248

Hello @as159925

  1. The following segment should be executed for both the cases when m=n and m!=n:
    if(arra[0]+arrb[0]>=10)
    n1=n+1;
    else if(arra[0]+arrb[0]<=9)
    n1=n;

  2. Also, the above-mentioned segment will fail for the case when arra[0]+arrb[0]=9 and the carry is 1 i.e. temp1.

  3. remove the following conditional loop:
    while(x>=0 or y>=0){}
    Reason:
    It won’t make any difference.

  4. The following condition may produce the wrong output for the case when either x<0 or y<0 which will occur when x<y or y<x.
    temp=arra[x]+arrb[y]+temp1;
    Solution:
    if(x!<0 && y!<0)
    temp=arra[x]+arrb[y]+temp1;
    else if(x!<0)
    temp=arra[x]+temp1;
    else if(y!<0)
    temp=arrb[y]+temp1;

Hope, this would help.
Give a like if you are satisfied.

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.