Sparse Matrix Multiplication
Given two sparse integer matrices A
and B
. Return the result of AB
.
Review the rules of multiple two matrices here
Below is a graphical demonstration of matrix multiplication:
A "sparse" matrix is a matrix where most entries are zero. You may assume that the number of columns in A
is equal to that of the number of rows in B
.
Input
a
: an integer matrix.b
: an integer matrix.
Output
An integer matrix represent the product of the above matrices.
Examples
Example 1:
Input:
1a = [[1, 0, 3], [0, 1, 2]] 2b = [[0, 1], [1, 3], [0, 0]]
Output: [[0, 1], [1, 3]]
Explanation:
Try it yourself
Solution
Title
Script
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem
Ipsum
has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
Contrary to popular belief, Lorem
Ipsum
is not simply random text.
1 >>> a = [1, 2, 3] 2 >>> a[-1] 3 3