[프로그래머스/Java] Lv.0 배열 회전시키기
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 class Solution { public int[] solution(int[] numbers, String direction) { int[] answer = new int[numbers.length]; switch(direction) { case "left" : //left로 이동시킬경우 int temp=numbers[0]; //매개변수로 들어온 배열의 첫번째 정수를 저장하고 for(int i=0; i0; i--) { answer[i]=numbers[i-1]; //나머지 정수를 한칸씩 오른쪽으로 옮긴후 } answer[0]=temp1; break; //저장했던 마지막 정수를 첫번째 자리에 넣음 } Colored by Col..