Skip to content

Files

Latest commit

 

History

History
32 lines (28 loc) · 822 Bytes

File metadata and controls

32 lines (28 loc) · 822 Bytes

Matrix Multiplication

Easy


  1. You are given for 1st matrix, no of rows(n1) and no of columns(m1)
  2. You are given n1*m1 numbers, representing elements of 2d array mat1.
  3. You are given for 2nd matrix, no of rows(n2) and no of columns(m2)
  4. You are given n2*m2 numbers, representing elements of 2d array mat2.
  5. If the two arrays can be multiplied, display the contents of multiplied array.
  6. Otherwise print "Invalid input".

Example 1:

Input:  
n1=2, m1=3, mat1[][] = {10, 0, 0, 0, 20, 0}
n2=3, m2=4, mat2[][] = {1, 0, 1, 0, 0, 1, 1, 2, 1, 1, 0, 0}

Output: 10 0 10 0 0 20 20 40

Constraints:

1 <= n1 <= 10^2
1 <= m1 <= 10^2
-10^9 <= e11, e12, .. n1 * m1 elements <= 10^9
1 <= n2 <= 10^2
1 <= m2 <= 10^2
-10^9 <= e11', e12', .. n2 * m2 elements <= 10^9