← 返回 amazon 的题目列表Add Two Numbers II Variant
类型:online_judge
Problem: Add Two Numbers in Forward Order
You are given two non-negative integers represented as arrays of digits. Each array stores digits in most-significant to least-significant order.
Return the sum of the two integers, also represented as an array of digits in most-significant to least-significant order.
Input Format
n
l1[0] l1[1] ... l1[n-1]
m
l2[0] l2[1] ... l2[m-1]
n is the length of the first digit array.
The second line contains n digits.
m is the length of the second digit array.
The fourth line contains m digits.
Output Format
Print the resulting digit array, separated by spaces.
Constraints
1 <= n, m <= 10^5
0 <= l1[i], l2[i] <= 9
Inputs contain no unnecessary leading zeros unless the number itself is 0.
You may not convert the whole array directly into an integer and add them.
Example
Input:
4
7 2 4 3
3
5 6 4
Output:
7 8 0 7
Explanation: 7243 + 564 = 7807.
Example
Input
4
7 2 4 3
3
5 6 4
Output
7 8 0 7