407. Sum of Two Numbers in Linked List Without Reverse

HardLinked ListStackLinked ListMath

Two non-negative integers are represented by linked lists with the most significant digit first. Compute their sum without reversing either list, and return the sum as a single integer. Input: '[l1], [l2]'.

Input: '[l1], [l2]'.

Output: Integer — the numeric sum.

Examples

Example 1
Input: [7,2,4,3], [5,6,4]
Output: 7807
Explanation: 7243 + 564 = 7807.
Example 2
Input: [2,4,3], [5,6,4]
Output: 807
Explanation: 243 + 564 = 807.
Example 3
Input: [0], [0]
Output: 0
Explanation: 0 + 0 = 0.

Constraints

Asked by

AmazonGoogleMicrosoftMetaAdobe
Solve this problem in the editor →