Trains the technique from
LeetCode 2784Check if Array is GoodThis 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 ticket roll is standard when, for some whole number k of at least 1, the numbers printed on it are exactly the numbers 1 through k each appearing once, plus a second copy of k. So a standard roll holds k + 1 tickets in total.
Return true when the roll nums is standard, and false otherwise.
Example 1
The roll holds four tickets, so a standard roll would need the numbers 1, 2 and 3 with a second 3. Sorted, the roll reads 1, 2, 3, 3, which is exactly that.
Example 2
Four tickets would need a second copy of 3, but every number here appears once and a 4 is present, so the roll is not standard.
Example 3
Three tickets need the numbers 1 and 2 with a second 2, and sorted the roll reads 1, 2, 2.
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_standard_roll(nums: list[int]) -> bool:public boolean isStandardRoll(int[] nums)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.