코딩테스트 예제
프로그래머스 배열뒤집기 예제
jineric
2023. 5. 12. 14:58
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;
}
}
// 배열 거꾸로 뒤집기 값이 있는 배열이 있고
// 새로운 배열에 값이 있는 배열의 길이를 넣는다.
// int[] b = new int[a.length];
// for문을 돌려 0~배열의길이까지
// answer[i] = a[a.length-i-1];