Write a function that, given two square matrices @a@ and @b@, computes their sum.
Interface
C++ | typedef vector< vector<int> > Matrix; |
Matrix sum(const Matrix& a, const Matrix& b); | |
Java | public static int[][] sum(int[][] a, int[][] b); |
Python | sum(a, b) # returns list |
sum(a: list[list[int]], b: list[list[int]]) -> list[list[int]] |
Precondition
@a@ and @b@ are square matrices n× n with n ≥ 0.