๋ฌธ์ ์ค๋ช
2์ฐจ์ ํ๋ ฌ arr1๊ณผ arr2๋ฅผ ์ ๋ ฅ๋ฐ์, arr1์ arr2๋ฅผ ๊ณฑํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋ ํจ์, solution์ ์์ฑํด์ฃผ์ธ์.
์ ํ ์กฐ๊ฑด
- ํ๋ ฌ arr1, arr2์ ํ๊ณผ ์ด์ ๊ธธ์ด๋ 2 ์ด์ 100 ์ดํ์ ๋๋ค.
- ํ๋ ฌ arr1, arr2์ ์์๋ -10 ์ด์ 20 ์ดํ์ธ ์์ฐ์์ ๋๋ค.
- ๊ณฑํ ์ ์๋ ๋ฐฐ์ด๋ง ์ฃผ์ด์ง๋๋ค.
์ ์ถ๋ ฅ ์
arr1 | arr2 | result |
[[1, 4], [3, 2], [4, 1]] | [[3, 3], [3, 3]] | [[15, 15], [15, 15], [15, 15]] |
[[2, 3, 2], [4, 2, 4], [3, 1, 4]] | [[5, 4, 3], [2, 4, 1], [3, 1, 1]] | [[22, 22, 11], [36, 28, 18], [29, 20, 14]] |
ํ์ด ์ฝ๋
def solution(arr1, arr2):
answer = [[0]*len(arr2[0]) for _ in range(len(arr1))]
for i in range(len(arr1)):
for j in range(len(arr2[0])):
for k in range(len(arr1[0])):
answer[i][j] += arr1[i][k] * arr2[k][j]
return answer
ํ๋ ฌ์ ์๋ฆฌ
'๐ ์ฝ๋ฉํ ์คํธ ๋๋น : PS' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ํ๋ก๊ทธ๋๋จธ์ค] ์ ์ ์ผ๊ฐํ (level3, python) (0) | 2022.09.09 |
---|---|
[ํ๋ก๊ทธ๋๋จธ์ค] H-Index (level2, python) (0) | 2022.09.09 |
[ํ๋ก๊ทธ๋๋จธ์ค] ์ ํ์ ์๊ฐ์ด๋ (level2, python) (0) | 2022.09.09 |
[ํ๋ก๊ทธ๋๋จธ์ค] [1์ฐจ]์บ์ (level2, python) (0) | 2022.09.09 |
[ํ๋ก๊ทธ๋๋จธ์ค] ์ต๊ณ ์ ์งํฉ (level3, python) (0) | 2022.09.09 |