solution
public static int[][] solution(int[][] arr1, int[][] arr2) {
int aRow = arr1.length;
int aCol = arr1[0].length;
// bRow = arr2.length; // aCol과 동일
int bCol = arr2[0].length;
int[][] res = new int[aRow][bCol];
for (int i = 0; i < aRow; i++) { // arr1의 row
for (int j = 0; j < bCol; j++) { // arr2의 col
for (int k = 0; k < aCol; k++) { // 순회하면서 곱셈, bRow = aCol
res[i][j] += arr1[i][k] * arr2[k][j];
}
}
}
return res;
}
time complexity
O(M * K * N)
M = row1 (number of rows in arr1)
N = col2 (number of cols in arr2)
K = col1 (shared dimension: columns of arr1/rows of arr2)