Trains the technique from
LeetCode 445Add Two Numbers IIThis 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.
Two whole numbers reach you as digit strips. A strip is a list of single digits
written the way you would read the number off a page, most significant digit
first, so [3, 0, 6] stands for three hundred and six. A strip always holds at
least one digit, and the only strip that may open with a 0 is the single-digit
strip [0].
Return the sum of the two numbers as a strip in the same format: most significant digit first, and with no leading zeros.
The strips stand in for singly linked lists, which can only be walked from the most significant digit onwards. Reach the low-order digits with a stack or by reversing rather than pasting the digits together into one integer value.
Example 1
The strips stand for 456 and 78. Their sum is 534, written as the strip [5,3,4].
Example 2
99 plus 1 is 100, so the answer strip is one digit longer than either input strip.
Example 3
0 plus 7 is 7, a single-digit strip.
Example 4
306 plus 194 is 500, written as [5,0,0].
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_two_numbers(first: list[int], second: list[int]) -> list[int]:public int[] addTwoNumbers(int[] first, int[] second)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.