Trains the technique from
LeetCode 306Additive NumberThis 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 stock-taking machine prints its readings onto a paper tape as one unbroken run of digits with nothing separating them. tape is that run.
The tape is consistent when its digits can be cut, left to right and with no digit left over, into three or more whole numbers such that every number from the third onwards equals the sum of the two numbers immediately before it.
No number in the cut may carry a leading zero. A single 0 is a legal number, but 07 and 012 are not.
Return true when the tape is consistent, and false otherwise.
Example 1
Cutting the tape as 4, 8, 12, 20, 32 uses every digit, and `4 + 8 = 12`, `8 + 12 = 20` and `12 + 20 = 32`, so the tape is consistent.
Example 2
Cutting the tape as 9, 0, 9, 9 uses every digit, and `9 + 0 = 9` and `0 + 9 = 9`. The single `0` is a legal number, so the tape is consistent.
Example 3
The cuts into three or more numbers are 5, 7, 1, 3 / 5, 7, 13 / 5, 71, 3 / 57, 1, 3, and none of them has every number from the third onwards equal to the sum of the two before it, so the tape is not consistent.
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 is_summing_tape(tape: str) -> bool:public boolean isSummingTape(String tape)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.