What is the problem in this sum of array code?

Hello @itismohiton,

  1. As in the first iteration of while loop you are accessing n,m and temp index which are not valid indexes for their corresponding arrays.

  2. Wrong if condition inside the second while loop.

I have corrected your code:

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

It is still not passing all test cases.

Hello @itismohiton,

Are you sure?
I myself tested it for all the test cases and it is giving correct output.

1 Like

Sorry, It’s passing all test cases now.