Cargando el ejercicio…
Imagine a list made of two halves that need to be woven together one item at a time. Given a list nums of length 2n, where the first half comes before the second half, return a new list that alternates between them. Take the first item from the first half, then the first item from the second half, then the second from each half, and so on.
[2, 5, 1, 3, 4, 7], 3[2, 3, 5, 4, 1, 7][1, 2, 3, 4, 4, 3, 2, 1], 4[1, 4, 2, 3, 3, 2, 4, 1][1, 1, 2, 2], 2[1, 2, 1, 2]def shuffle(nums: list[int], n: int) -> list[int]:
Inicia sesión para ver tu historial de envíos
Iniciar sesiónInicia sesión para usar el AI Mentor
Iniciar sesión[2,5,1,3,4,7], 3[2,3,5,4,1,7][1,2,3,4,4,3,2,1], 4[1,4,2,3,3,2,4,1][1,1,2,2], 2[1,2,1,2][5,10], 1[5,10][1,2,3,4,5,6], 3[1,4,2,5,3,6][2,5,1,3,4,7,2], 0[]