An arena's digital scoreboard displays the home team's running point total as a row of individual digit tiles, most significant digit first, with no leading-zero tile unless the total itself is exactly zero. After a scoring play worth k points, the operator needs the new tile arrangement without ever reconstructing the whole number as a single machine integer internally tile-by-tile — the update must work directly on the digit tiles the way the physical board does, propagating any carry leftward.
Given the current digit tiles and the point increment k, compute the digit tiles of current_value + k.
Line 1: an integer n, the number of digit tiles.
Line 2: n space-separated integers d_1 d_2 ... d_n (each 0 <= d_i <= 9), the current digits most significant first. d_1 is not 0 unless n == 1.
Line 3: an integer k, the number of points to add.
A single line of space-separated digits, most significant first, representing current_value + k, with no leading zeros (print a single 0 if the result is exactly zero).
1 <= n <= 10000.
0 <= k <= 10000.
Example 1
Input
3 1 2 0 34
Expected
1 5 4
Explanation
The scoreboard shows 120. Adding 34 points gives 154, whose digit tiles are 1, 5, 4.
Example 2
Input
1 0 0
Expected
0
Explanation
The scoreboard shows a single 0 tile and no points are added, so it stays 0.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →