ans
with dimensions m x n
, filled with zeros.i
of mat1
.i
, iterate over each column j
of mat2
.(i, j)
, compute the dot product of the i
-th row of mat1
and the j
-th column of mat2
:
a. Initialize a sum variable to 0.
b. Iterate over each element k
in the i
-th row of mat1
.
c. Multiply mat1[i][k]
by mat2[k][j]
and add the result to the sum variable.
d. After iterating through all elements, assign the sum to ans[i][j]
.ans
.