← 返回 bytedance 的题目列表Plus One (Array of Digits)
类型:online_judge
Given an array digits of integers (0-9) representing a non-negative integer in decimal (most significant digit first), add 1 to the integer and return the resulting array of digits.
Notes
The number can be very large, so you must not convert it to an integer directly.
Input
Line 1: integer n, the length of the array.
Line 2: n integers in 0..9, the array digits.
Output
One line: the resulting digits separated by spaces.
Constraints
1 <= n <= 1e5
0 <= digits[i] <= 9
Example
Input:
3
1 2 9
Output:
1 3 0
Example
Input
3
1 2 9
Output
1 3 0