119. Add Digit Lists
mediumlinked listmath
Two non-negative integers are stored as linked lists of digits in reverse order (ones digit first). Return their sum as a list in the same format.
The list arrives as a ListNode (val, next). Tests show lists as arrays.
Example 1
Inputl1 = [2,4,3], l2 = [5,6,4]
Output[7,0,8]
Example 2
Inputl1 = [0], l2 = [0]
Output[0]
Example 3
Inputl1 = [9,9,9,9], l2 = [9,9]
Output[8,9,0,0,1]
Constraints
- 1 ≤ length ≤ 100
- no leading zeros except the number 0