programmers_행렬의 곱셈_java
2023. 4. 4. 17:42ㆍAlgorithm/Programmers
728x90
https://school.programmers.co.kr/learn/courses/30/lessons/12949
class Solution {
public int[][] solution(int[][] arr1, int[][] arr2) {
int arr1Hieght = arr1.length;
int arr1Width = arr1[0].length;
int arr2Hieght = arr2.length;
int arr2Width = arr2[0].length;
int[][] answer = new int[arr1Hieght][arr2Width];
for(int i = 0; i< arr1Hieght; i++){
for(int j = 0; j < arr2Width; j++){
answer[i][j] = 0;
for(int k = 0; k < arr1Width; k++){
answer[i][j] += arr1[i][k] * arr2[k][j];
}
}
}
return answer;
}
}
'Algorithm > Programmers' 카테고리의 다른 글
programmers_n^2 배열 자르기_java (0) | 2023.04.05 |
---|---|
programmers_튜플_java (0) | 2023.04.04 |
programmers_귤 고르기_java (0) | 2023.04.04 |
programmers_괄호 회전하기_java (0) | 2023.04.04 |
programmers_멀리 뛰기_java (0) | 2023.04.04 |