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.

Interview Code Editor
Hints
  • Solution Approach
  • Complete Solution
6515 successful submissions.
Asked In:
  • Amazon
  • Qualcomm
  • Microsoft
  • Facebook
Click here to jump start your coding interview preparation