public int[][] solution(int[][] arr1, int[][] arr2) {
int rowsA = arr1.length;
int colsA = arr1[0].length;
int colsB = arr2[0].length;
int[][] result = new int[rowsA][colsB];
for (int i = 0; i < rowsA; i++) {
for (int j = 0; j < colsB; j++) {
result[i][j] = calculateElement(arr1, arr2, i, j, colsA);
}
}
return result;
}
private int calculateElement(int[][] arr1, int[][] arr2, int row, int col, int colsA) {
int sum = 0;
for (int k = 0; k < colsA; k++) {
sum += arr1[row][k] * arr2[k][col];
}
return sum;
}
출처:https://school.programmers.co.kr/learn/courses/30/lessons/12949