Make Unreal REAL.
article thumbnail
Level 2. 행렬의 곱셈

 

 

#include <iostream>
#include <vector>

using namespace std;

vector<vector<int>> solution(vector<vector<int>> arr1, vector<vector<int>> arr2)
{
    size_t M = arr1.size(), K = arr2.size(), N = arr2.front().size();
    vector<vector<int>> answer(M, vector<int>(N, 0));

    for (int row = 0; row < M; ++row)
        for (int col = 0; col < N; ++col)
            for (int i = 0; i < K; ++i)
                answer[row][col] += arr1[row][i] * arr2[i][col];

    return answer;
}

'자료구조 & 알고리즘 > 프로그래머스' 카테고리의 다른 글

Level 2. 프린터  (0) 2023.03.31
Level 2. 올바른 괄호  (0) 2023.03.30
Level 2. 쿼드압축 후 개수 세기  (0) 2023.03.28
Level 2. 방문 길이  (0) 2023.03.27
Level 2. 짝지어 제거하기  (0) 2023.03.26
profile

Make Unreal REAL.

@diesuki4

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!

검색 태그