CiscoOA #8
Add Numbers
Estimated EasyJudge-ready
Topics (AI-labelled)SimulationIn-place ArraysBits & Math
Two non-negative integers are represented as digit lists with the ones digit first; compute their sum and output it in the same reversed order. The input may contain high-order 0s; this site always removes extra high-order 0s from the result, and zero is output as a single 0.
Input
The input is the length n, n digits, the length m, and m digits, in that order. The original gave no numeric bounds; this site adds 1≤n,m≤100000, with each item in 0..9.
Output
Output the normalized reversed digits separated by spaces, without the length. Zero is output as a single 0.
Example 1
Input:
3
2 4 6
3
8 0 9
Output:
0 5 5 1
Example 2
Input:
1
9
1
1
Output:
0 1
Example 3
Input:
2
0 0
1
0
Output:
0
Example notes
The outputs of the three public examples are, in order: 0 5 5 1; 0 1; 0. Verified by independent enumeration or direct simulation.
Editorial
Loading solution…