Add Two Numbers (Linked List)

Medium
Linked Lists Math Recursion
You are given two non-empty linked lists representing two non-negative integers stored in reverse order. Each node contains a single digit. Add the two numbers and return the sum as a linked list. Input format: two lines, each containing space-separated digits.

Constraints

Each linked list has 1-100 nodes. 0 <= Node.val <= 9 Numbers do not contain leading zeros except 0 itself.

Examples

Example 1:
Input: 2 4 3 5 6 4
Output:
Explanation: 342+465=807
Example 2:
Input: 0 0
Output:

Hints

Process digit by digit with carry.
Don't forget the final carry.
▲ Console

Install Talent Arabia

Get instant access to jobs and career tools on your device.