배열 뒤집기
📃 문제
🔨 풀이
1
2
3
4
5
6
7
8
9
class Solution {
public int[] solution(int[] num_list) {
int[] answer = new int[num_list.length];
for(int i = 0;i<num_list.length;i++){
answer[i]=num_list[num_list.length-i-1];
}
return answer;
}
}
동일한 길이를 갖는 answer배열 생성
루프를 통해 역순으로 값을 할당
This post is licensed under CC BY 4.0 by the author.