Fácil15 pts
Rotate Array
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, rotate it to the right by k steps. Example: [1,2,3,4,5,6,7], k=3 → Rotate right 3 times → [5,6,7,1,2,3,4] Optimized approach: Use the reversal algorithm - reverse entire array, reverse first k, reverse rest.
Entrada
Line 1: n k (array size and rotation count). Line 2: n space-separated integers.
Salida
The rotated array as space-separated integers.
Ejemplo
7 3 1 2 3 4 5 6 7
Esperado
5 6 7 1 2 3 4
Loading editor…
Resultado
Sin salida aún. Ejecuta tu código para ver resultados.