Medium

Quiz

#445 Add Two Numbers II

APPROACH

Two non-empty singly linked lists represent non-negative integers with the most significant digit at the head, one digit per node, and no leading zeros (except for the number zero itself). Return a new linked list representing their sum in the same format.

Example 1:

Input: l1 = [7,2,4,3], l2 = [5,6,4]
Output: [7,8,0,7]

Example 2:

Input: l1 = [2,4,3], l2 = [5,6,4]
Output: [8,0,7]

Example 3:

Input: l1 = [0], l2 = [0]
Output: [0]
1 of 4
1:00

What is the optimal approach for this problem?