You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.
You may assume the two numbers do not contain any leading zero, except the number 0 itself.
This problem is straight forward, but consider the cases:
We should not forget the carry, especially when we have one more digit just for the carry. (e.g., 5 + 7 = 12, the ’1′ in 12 is due to the carry from last digit)
Two numbers might not have same number of digits. (e.g., 1 + 123 are one digit and three digit numbers)
As the link list are reversed that of number, we have taken care of adding it from right to left i.e. least significant digit to most significant digit.