[프로그래머스]2차원으로 만들기

박예림·2023년 4월 10일
0

코테

목록 보기
64/132

class Solution {
    public int[][] solution(int[] num_list, int n) {
        int[][] answer = new int[num_list.length/n][n];
        int num = 0;

        for (int i = 0;  i< num_list.length/n; i++) {
            for (int j = 0; j < n; j++) {
                answer[i][j] = num_list[num];
                num++;
            }
        }
        return answer;
    }
}
profile
응애 나 아기개발자

0개의 댓글