Skip to content

Commit 0f85284

Browse files
authored
[20251029] PGM / LV2 / 행렬의 곱 / 이인희
1 parent ac318e5 commit 0f85284

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
```java
2+
import java.util.*;
3+
4+
class Solution {
5+
public int[][] solution(int[][] arr1, int[][] arr2) {
6+
int rows = arr1.length;
7+
int cols = arr2[0].length;
8+
int common = arr2.length;
9+
int[][] answer = new int[rows][cols];
10+
11+
for(int i = 0; i < rows; i++){
12+
for(int j = 0; j < cols; j++){
13+
int sum = 0;
14+
for(int k = 0; k < common; k++){
15+
sum += arr1[i][k] * arr2[k][j];
16+
}
17+
answer[i][j] = sum;
18+
}
19+
}
20+
21+
return answer;
22+
}
23+
}
24+
```

0 commit comments

Comments
 (0)