Linked Lists Sum

LINKED LIST

Problem

Given two non-empty linked lists head1 and head2 representing two non-negative integers, where each node contains a single digit and the digits are stored in reverse order, 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.

Examples

addTwoNumbers([1,2,3], [4,5,6]) // returns [5,7,9] // 321 + 654 = 975
Loading...
1
2
3
4
5
6