Fácil15 pts
Move Zeroes to End
Traducción al español en progresoEl contenido detallado de esta lección aún se está traduciendo. Mientras tanto, se muestra en inglés.
Given an array of integers, move all zeroes to the end while maintaining the relative order of non-zero elements. Use two pointers: one for the position to insert non-zero, one to scan. Example: [0,1,0,3,12] → [1,3,12,0,0]
Entrada
Line 1: n. Line 2: n space-separated integers.
Salida
The array with zeroes moved to end, space-separated.
Ejemplo
5 0 1 0 3 12
Esperado
1 3 12 0 0
Loading editor…
Resultado
Sin salida aún. Ejecuta tu código para ver resultados.