Skip to content

Commit adac814

Browse files
committed
Matrix multiplication / 심화
1 parent 570393f commit adac814

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const solution = (arr1, arr2) => {
2+
// 결과 행렬 크기 생성
3+
const result = Array.from({ length: arr1.length }, () =>
4+
Array(arr2[0].length).fill(0)
5+
);
6+
7+
// 행렬 요소 하나씩 값 만들기
8+
return result.map((row, i) =>
9+
r.map((item, j) => {
10+
return arr1[i].reduce((acc, cur, k) => acc + cur * arr2[k][j], 0);
11+
})
12+
);
13+
};

0 commit comments

Comments
 (0)