first and second. Each node holds one digit, and the digits go from the most significant to the least significant, the way the number is written on paper. For instance, 503 is stored as 5 → 0 → 3.
Return their sum as a list in the same format, most significant digit first.
Both lists are non-empty and have no leading zeros, except the number 0 itself, which is a single node.
Try to do it without reversing the input lists.first=list_node([3, 0, 8]), second=list_node([9, 5]) → [4, 0, 3]
The lists encode 308 and 95; 308 + 95 = 403.
first=list_node([9, 9, 9]), second=list_node([2]) → [1, 0, 0, 1]
999 + 2 = 1001: the carry ripples through every digit and the result gains a new leading digit.
first=list_node([0]), second=list_node([6, 1]) → [6, 1]
0 + 61 = 61.
Node.val ≤ 9first=list_node([3, 0, 8]), second=list_node([9, 5])
[4, 0, 3]
Run checks the first 3 tests in your browser. Submit checks all 62 tests on the server, hidden ones included.