[Codility]CyclicRotation
[문제] [답안작성] class Solution { public int[] solution(int[] A, int K) { if( A.length == K || A.length == 1 || A.length == 0 ) { return A; } int temp = 0; for( int i = 0; i < K; i++ ) { for( int j = 0; j < A.length; j++ ) { int t = 0; if( j == A.length - 1 ) { A[0] = A[j]; A[j] = temp; } else { t = A[j]; A[j] = temp; temp = t; } } } return A; } }
Development/알고리즘
2020. 6. 27. 17:10