Linked ListMathSimulation
Two non-negative integers are stored as linked lists, one digit per node, with the least significant digit first (so 342 is stored as 2 -> 4 -> 3). Add the two numbers and print the sum in the same reversed-digit form. The values are given as an array; build the linked list from them yourself, then solve it with pointers.
Input
Line 1: n and m, the digit counts. Line 2: the n digits of the first number, least significant first. Line 3: the m digits of the second number, least significant first.
Output
Print the digits of the sum, least significant first, separated by spaces.
Constraints
1 <= n, m <= 100 0 <= each digit <= 9 No number has leading zeros, except the number 0 itself.
Example 1
Input
3 3 2 4 3 5 6 4
Output
7 0 8
342 + 465 = 807, stored as 7 0 8.