码迷,mamicode.com
首页 > 其他好文 > 详细

[LeetCode] Sparse Matrix Multiplication 稀疏矩阵相乘

时间:2016-03-16 13:45:22      阅读:277      评论:0      收藏:0      [点我收藏+]

标签:

 

Given two sparse matrices A and B, return the result of AB.

You may assume that A‘s column number is equal to B‘s row number.

Example:

A = [
  [ 1, 0, 0],
  [-1, 0, 3]
]

B = [
  [ 7, 0, 0 ],
  [ 0, 0, 0 ],
  [ 0, 0, 1 ]
]


     |  1 0 0 |   | 7 0 0 |   |  7 0 0 |
AB = | -1 0 3 | x | 0 0 0 | = | -7 0 3 |
                  | 0 0 1 |

 

 

 

s

[LeetCode] Sparse Matrix Multiplication 稀疏矩阵相乘

标签:

原文地址:http://www.cnblogs.com/grandyang/p/5282959.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!