Trains the technique from
LeetCode 989Add to Array-Form of IntegerThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A mechanical counter shows its reading as digits, one decimal digit per wheel, listed from the most significant wheel to the least significant one. The reading carries no leading zero unless it is the single digit 0.
The counter is now advanced by step units. Return the new reading in the same form, most significant digit first and with no leading zero. The strip gains a wheel at the front when the reading needs one.
Example 1
The reading 999 advanced by 1 unit becomes 1000, which needs a fourth wheel, so the strip is [1, 0, 0, 0].
Example 2
The reading 1407 advanced by 93 units becomes 1500, so the strip is [1, 5, 0, 0].
Example 3
The reading 0 advanced by 10000 units becomes 10000, so four wheels are added at the front.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def add_to_array_form(digits: list[int], step: int) -> list[int]:public List<Integer> addToArrayForm(int[] digits, int step)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.