본문 바로가기

Coding Test/프로그래머스

[프로그래머스/자바] 배열 뒤집기

class Solution {
    public int[] solution(int[] num_list) {
        int[] list = new int[num_list.length];
        for(int i=0; i<num_list.length; i++){
            list[i] = num_list[num_list.length-1-i];
        }
        return list;
    }
}

import java.util.*;

class Solution {
    public int[] solution(int[] num_List) {
        List<Integer> list = Arrays.stream(num_List).boxed().collect(Collectors.toList());
        Collections.reverse(list);
        return list.stream().mapToInt(Integer::intValue).toArray();
    }
}