Učitavanje zadatka…
The stack is given as a list: the bottom is on the left, and the top is on the right. Given stack, go through its elements from bottom to top in pairs. Swap the two elements in each pair. If there is an odd number of elements, leave the final top element unchanged.
[3, 8, 17, 9, 1, 10][8, 3, 9, 17, 10, 1][3, 8, 17, 9, 1][8, 3, 9, 17, 1][][]def switch_pairs(stack: list[int]) -> list[int]:
Prijavi se da vidiš povijest predaja
PrijavaPrijavi se da koristiš AI mentora
Prijava[3,8,17,9,1,10][8,3,9,17,10,1][3,8,17,9,1][8,3,9,17,1][][][1,2][2,1][10,1,9,17,8,3][1,10,17,9,3,8][1,2,3][2,1,3]