40. Add Two Numbers

Two non-negative numbers are stored as linked lists with digits in reverse order (the head is the ones digit). Return their sum as a linked list in the same format.

Example 1

Input: l1 = [2,4,3], l2 = [5,6,4]
Output: [7,0,8]
Explanation: 342 + 465 = 807

Example 2

Input: l1 = [9,9], l2 = [1]
Output: [0,0,1]
Explanation: 99 + 1 = 100
Hint 1

Add digit by digit like on paper, carrying into the next node.

Hint 2

Keep looping while either list or the carry is non-empty.

Linked ListMath