370. Add Two Numbers as Lists
MediumLinked ListMath
Two non-negative numbers are stored as lists of digits in reverse order (the head is the ones digit). Print their sum in the same reverse-digit format.
Input format
Line 1: n Line 2: n digits Line 3: m Line 4: m digits
Output format
The sum's digits, reversed.
Example 1
Input
3 2 4 3 3 5 6 4
Output
7 0 8
Example 2
Input
1 0 1 0
Output
0
Constraints
1 ≤ n, m ≤ 100
Read input from standard input and print the answer to standard output. Your code is judged against 3 test cases, most of them hidden.
Loading the MyLoginn IDE…