Add Two Numbers as Lists

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.

Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)
Output: 7 -> 0 -> 8

    342 + 465 = 807

Make sure there are no trailing zeros in the output list
So, 7 -> 0 -> 8 -> 0 is not a valid response even though the value is still 807.

NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Add Two Numbers as Lists on Interview Code Editor
Sign Up
to access hints and editorial solutions for Add Two Numbers as Lists
10291 successful submissions.
Asked In:
  • Amazon
  • Qualcomm
  • Microsoft
  • Facebook
Click here to start solving coding interview questions