Add Two Numbers
You are given two non-empty linked lists representing two non-negative integers, with digits stored in reverse order (ones digit first) and each node holding a single digit. Add the two numbers and return the sum as a linked list in the same reverse-order form.
Open official problem prompt ↗Compute the sum of two integers given as reversed digit lists and return the result in the same reversed-list form.
Adding two numbers on paper starting from the rightmost column, carrying a 1 into the next column whenever a column total reaches ten.
- Input
- l1 = [2, 4, 3], l2 = [5, 6, 4]
- Output
- [7, 0, 8]
- Why
- l1 represents 342 and l2 represents 465; 342 + 465 = 807, which stored ones-first is [7, 0, 8].
The number of nodes in each list is in the range [1, 100]0 <= Node.val <= 9Each number has no leading zeros except the number 0 itself