
-Code
class Solution {
public int[][] solution(int[][] arr1, int[][] arr2) {
// 결과로 반환할 배열 선언
int totalRow = arr1.length;
int totalCol = arr2[0].length;
int[][] answer = new int[totalRow][totalCol];
// 계산시 사용하는 arr1은 col부분, arr2는 row부분 횟수
int calcCnt = arr1[0].length;
for (int row = 0; row < totalRow; row++) {
for (int col = 0; col < totalCol; col++) {
// arr1의 가로와 arr2의 세로를 곱한후 합
for(int calc = 0; calc < calcCnt; calc++) {
answer[row][col] += arr1[row][calc] * arr2[calc][col];
}
}
}
return answer;
}
}'Beakjoon&프로그래머스 > Java' 카테고리의 다른 글
| [프로그래머스/Java] 점프와 순간 이동 (0) | 2026.01.02 |
|---|---|
| [프로그래머스/Java] 멀리 뛰기 (0) | 2026.01.02 |
| [프로그래머스/Java] 구명보트 (0) | 2026.01.02 |
| [백준/Java] 20733번 Triple Texting (0) | 2026.01.02 |
| [프로그래머스/Java] 타겟 넘버 (0) | 2026.01.01 |