import java.util.Arrays;
class Solution {
public int[] solution(int[] numbers, String direction) {
int[] answer = new int[numbers.length]; // numbers배열과 같은 크기로 잡아줌
if (direction.equals("left")){
for (int i = 0; i < numbers.length - 1; i++) {
answer[i] = numbers[i + 1];
}
answer[answer.length - 1] = numbers[0];
} else if (direction.equals("right")) {
for (int i = 1; i < numbers.length; i++) {
answer[i] = numbers[i - 1];
}
answer[0] = numbers[numbers.length-1];
}
return answer;
}
}
https://school.programmers.co.kr/learn/courses/30/lessons/120844?language=java