✏️ 작성한 코드
class Solution {
public int[][] solution(int[] num_list, int n) {
int[][] answer = new int[num_list.length/n][n];
int idx = 0;
for(int i = 0; i < num_list.length/n; i++){
for(int j = 0; j < n ; j++){
answer[i][j] = num_list[idx];
idx++;
}
}
return answer;
}
}
행/열 헷갈리지 않게 조심!
'Algorithm > 프로그래머스' 카테고리의 다른 글
[Lv. 0] 진료 순서 정하기 (0) | 2023.04.03 |
---|---|
[Lv. 0] K의 개수 (0) | 2023.03.30 |
[Lv. 0] 팩토리얼 (0) | 2023.03.30 |
[Lv. 0] A로 B 만들기 (0) | 2023.03.28 |
[Lv. 0] 모스부호(1) (0) | 2023.03.28 |
댓글