Add Two Numbers
Given two non-empty linked lists representing two non-negative integers stored in reverse order, add them and return the sum as a linked list.
Add Two Numbers

Given two non-empty linked lists representing two non-negative integers stored in reverse order, add them and return the sum as a linked list.

Example 1:
Input: {"l1":[2,4,3],"l2":[5,6,4]}
Output: [7,0,8]
Input
arr ={"l1":[2,4,3],"l2":[5,6,4]}
Start adding
L1 (First Number)
2
4
3
null
Represents: 342
L2 (Second Number)
5
6
4
null
Represents: 465
Carry
0
Result
Building...
Represents: ...
Algorithm:
• Numbers are stored in reverse order (342 → 2→4→3)
• Add digit by digit with carry
• sum = l1.val + l2.val + carry
• new digit = sum % 10, carry = sum / 10
Variables
VariableValue
l1Len3
l2Len3
DepthFunction Call
Stack empty
0/4