leetcode icon indicating copy to clipboard operation
leetcode copied to clipboard

A little bug in No.2 Add two numbers

Open Travelmind opened this issue 4 years ago • 1 comments

The while condition should add carry != 0, like this:

while( l1 != null || l2 != null || carry ==1){ }

otherwise, it cannot pass the test case like: [9,9,9,9,9,9,9] [9,9,9,9]

output should be: [8,9,9,9,0,0,0,1] but it missed the highest [1]

thx

Travelmind avatar Oct 20 '21 01:10 Travelmind