Duplicate Each Item
Sometimes you need to duplicate data while keeping the original order, like making two identical cards in a row. Given a stack stack represented as a list, return a new list where each element appears twice consecutively. If the stack is empty, return an empty list.
Примеры
Ввод
[3, 7, 1, 14, 9]Вывод
[3, 3, 7, 7, 1, 1, 14, 14, 9, 9]Ввод
[]Вывод
[]Ввод
[5]Вывод
[5, 5]Нужно реализовать
def stutter(stack: list[int]) -> list[int]:
Теги
stack
Logáil isteach chun stair na n-aighneachtaí a fheiceáil
Logáil isteachLogáil isteach chun an Meantóir IS a úsáid
Logáil isteachTests12
Visible tests
Tástáil fholaithe 7
Tástáil fholaithe 8
Tástáil fholaithe 9
Tástáil fholaithe 10
Tástáil fholaithe 11
Tástáil fholaithe 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