Two non-negative whole numbers are stored as linked lists of digits in reverse order: the first node is the ones digit. So 2 -> 4 -> 3 is the number 342. Add the numbers and return the sum in the same format.
The tests show a list as a Python list of its values: [1, 2, 3] stands for 1 -> 2 -> 3.
Example 1
Input:
add_two_numbers(l1, l2) # l1 = 2 -> 4 -> 3 (342), l2 = 5 -> 6 -> 4 (465)
Output:
[7, 0, 8]
Example 2
Input:
add_two_numbers(l1, l2) # l1 = 9 -> 9 -> 9 (999), l2 = 1
Output:
[0, 0, 0, 1]
1 <= number of nodes <= 100000 in each list0 <= val <= 90 appears only in the number 0 itself).No results yet
Run your code to check it against the examples, or submit to run every test.