Watch 10 video solutions for Add Two Numbers II, a medium level problem involving Linked List, Math, Stack. This walkthrough by NeetCode has 293,331 views views. Want to try solving it yourself? Practice on FleetCode or read the detailed text solution.
You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.
You may assume the two numbers do not contain any leading zero, except the number 0 itself.
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]
Constraints:
[1, 100].0 <= Node.val <= 9
Follow up: Could you solve it without reversing the input lists?