# Question

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

You may assume the two numbers do not contain any leading zero, except the number 0 itself.

Example:

Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)
Output: 7 -> 0 -> 8
Explanation: 342 + 465 = 807.

Code provided:

# Solution

source: leetcode

## En

Before starting summing up two lists, create a new linked list to store the summed up value. Given $l1$ and $l2$, starting with the head of $l1$ and $l2$. Each digit is in the range of $0...9$, so it is possible that summing two digits may result in a value that is greater than 9, therefore require $2$ digits to represent. Hence, extra digit is needed during each iteration to carry the overflowing value.

# Complexity Analysis

• Time Complexity:

• Space Complexity:

# Reference

Python solution - 80ms - Easy to read

Solution