java
import java.util.Collections; import java.util.Arrays; class Solution { public int[] solution(int[] A, int K) { // write your code in Java SE 8 if ( A.length < 2) { return A;} int rotation = K % A.length; if (rotation==0) { return A; } int[] temp = new int[A.length]; System.arraycopy(A, 0, temp, rotation, A.length - rotation); System.arraycopy(A, A.length-rotation, temp, 0, rotation); return temp; } }
'Computer Science > 알고리즘 ( Algorithm )' 카테고리의 다른 글
Codility - StoneWall (0) | 2019.03.11 |
---|---|
Codility - Nesting (0) | 2019.03.11 |
Codility - Binary gap (0) | 2019.03.11 |
카카오 오픈채팅방 (0) | 2019.01.30 |
python string 다루기 (0) | 2019.01.01 |