// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int[] A, int K) {
// write your code in Java SE 8
int len = A.length;
int[] result = new int[len];
for (int i = 0; i < len; i++) {
int movedIdx = (i + K) % len;
result[movedIdx] = A[i];
}
return result;
}
}
'알고리즘' 카테고리의 다른 글
[codility] lesson5 - PassingCars (0) | 2020.08.14 |
---|---|
[codility] lesson4 - FrogRiverOne (0) | 2020.08.13 |
[codility] lesson3 - FrogJmp (0) | 2020.08.12 |
[codility] Lesson1 - Binary Gap (0) | 2020.08.12 |
[codility] lesson2 - OddOccurrencesInArray (0) | 2020.08.12 |