Algorithm · Voleon · Medium
Implement sparse matrix addition and multiplication through a dispatcher. A matrix is represented as [r, c, entries], where r is the row count, c is the column count, and entries is a list of [row, col, value] triples for non-zero cells. Row and column indices are zero-based. A single matrix may contain more than one triple for the same (row, col); all such values should be summed. Implement solution(op, A, B) as follows: If op == "add", return A + B. The shapes must match…
Checking your access…