Left Rotation
Shifting a list is like a carousel: the first element moves to the end, and everything else moves one position to the left. Write a function shift_left that takes a list nums and returns a new list after this shift. If the list has one element, it stays the same.
Примеры
Ввод
[1, 2, 3]Вывод
[2, 3, 1]Ввод
[1, 2]Вывод
[2, 1]Ввод
[1]Вывод
[1]Нужно реализовать
def shift_left(nums: list[int]) -> list[int]:
Теги
listsarray
Connectez-vous pour voir l'historique des soumissions
Se connecterConnectez-vous pour utiliser le Mentor IA
Se connecterVisible tests
1
Input
[1,2,3]Expected
[2,3,1]2
Input
[1,2]Expected
[2,1]3
Input
[1]Expected
[1]4
Input
[]Expected
[]5
Input
[5,6,7,8]Expected
[6,7,8,5]6
Input
[2,1]Expected
[1,2]Focus radio
Paused · SomaFM · Fluid