Trains the technique from
LeetCode 2996Smallest Missing Integer Greater Than Sequential Prefix SumThis 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 gym's handover log lists the locker codes handed out today, in the order they were handed out, as nums.
Look at the front of the log. A run of codes starting at the very first entry is called a ladder when every code in it is exactly one above the code before it; the first entry on its own always counts as a ladder. Let total be the sum of the codes in the longest ladder the log begins with.
Return the smallest integer that is at least total and does not appear anywhere in nums.
Example 1
The log begins with the ladder 4, 5, 6, because 2 does not follow 6. Its codes add up to 15, and 15 never appears in the log.
Example 2
The longest ladder at the front is 7, 8, which totals 15. The log already shows 15, 16 and 17, so the first value at or above 15 that is free is 18.
Example 3
20 does not follow 9, so the ladder holds only the code 9 and the total is 9. The log shows 9 itself, and 10 is free.
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 missing_integer(nums: list[int]) -> int:public int missingInteger(int[] nums)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.