Given an array of integers, rotate the array by 'N' elements.

Descripción

Fichas sobre Given an array of integers, rotate the array by 'N' elements., creado por Suhas S el 12/02/2018.
Suhas S
Fichas por Suhas S, actualizado hace más de 1 año
Suhas S
Creado por Suhas S hace más de 6 años
0
0

Resumen del Recurso

Pregunta Respuesta
Given an array of integers, rotate the array by 'N' elements. class Solution { public void rotate(int[] nums, int k) { k = k%nums.length; reverse(nums, 0 , nums.length -1); reverse(nums, 0 , k - 1); reverse(nums, k , nums.length -1 ); } public void reverse(int[] nums,int start,int end){ while( start < end){ int temp = nums[start]; nums[start] = nums[end]; nums[end] = temp; start++; end--; } } }
Mostrar resumen completo Ocultar resumen completo

Similar

PHP Exam One
tr.badhan
Array Programs
Subash M
Array
alim586
Array
Tate Johnson
Test Card
Nick Wu
Single sell stock
Suhas S
Remove Duplicates from Sorted Array
Suhas S
Fracciones y porcentajes
Esperanza Gesteira
FRANQUISMO (1939-1975)
Juan Cano Molina
Mapa Conceptual Resolucion 1995 de 1999
alsalazar5