Code
Loading editor...
Tap Analyze to see visualization
Click Analyze to visualize
See step-by-step execution, variables, and output
Variables
Run code to see variables
Output
Console output will appear here
Click Analyze to visualize
See step-by-step execution, variables, and output
Run code to see variables
Console output will appear here
Use a dummy node to build the result list. Traverse both input lists simultaneously, summing corresponding digits plus any carry from the previous column. Create a new node for each digit and propagate the carry until both lists and the carry are exhausted.
Since digits are stored in reverse order, the head of each list is the ones place, which is exactly where addition starts. Processing left to right mirrors grade-school addition from least significant to most significant digit.
Updated Feb 2026