Cyclic Rotation - practice for Codility test - JavaScript for loop

preview_player
Показать описание
In this video I'm using JavaScript for loop to find the result of performing cyclic rotation on an array.

This task is called CyclicRotation and is from Codility's second lesson. I'm preparing for a Codility test and that's why I'm solving these tasks. I decided to share my solutions here so hopefully they can help you :)

You can access this task from the following link:

I'm just starting with YouTube, so I'll try to improve the quality of my videos as I go forward :) Please let me know in the comments bellow if something is unclear.
Рекомендации по теме
Комментарии
Автор

Thank you for the video, I'm learning a lot from you from other Codility videos you made.
Here is my approach, it also got 100% score from Codility ;

function solution(A, K) {
if(A.length==0)return A;
for(let i=0 ; i<K ; i++){
A.unshift(A.pop());
}
return A;
}

selinsuvarol
Автор

I just did the following with successfully result:

function solution(A, K) {
for (var i =0; i < K; i++) {
A.unshift(A[A.length-1])
A.pop()
}
return A
}

I'm missing something? I think this solution works too (I'm learning too)

GabrielMazzoleni
welcome to shbcf.ru