One-Step Stack
Here you need to check whether the values in a stack form a clean increasing chain. Given stack, where the bottom is on the left and the top is on the right, return True if each next element is exactly 1 greater than the previous one. If this order breaks even once, return False.
Примеры
Ввод
[3, 4, 5, 6, 7]Вывод
TrueВвод
[3, 4, 6, 7]Вывод
FalseВвод
[3, 2, 1]Вывод
FalseНужно реализовать
def is_consecutive(stack: list[int]) -> bool:
Теги
stack
Zaloguj się, aby zobaczyć historię rozwiązań
Zaloguj sięZaloguj się, aby korzystać z Mentora AI
Zaloguj sięTests12
Visible tests
Ukryty test 7
Ukryty test 8
Ukryty test 9
Ukryty test 10
Ukryty test 11
Ukryty test 12
They run when you press "Submit" — your whole solution is checked against them so you can't hard-code answers for the visible cases.
Focus radio
Paused · SomaFM · Fluid