Is there something wrong with the test case and expected output?


  • 2
    J

    Test case:
    {9, 8}, {1}
    output:{9, 9}
    expected{0, 9}

    98+1=99.
    how come it expects 90?


  • 2
    S

    The digits are stored in reverse order and each of their nodes contain
    a single digit.

    Pay attention to this statement.
    So the {9, 8} means 89, not 98.


  • 7

    From the problem statement,

    You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.

    So it should be 89 + 1 = 90.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.