Matrix-vector multiplication
Implement matrix-vector multiplication from scratch. Given a matrix as a list of rows (each row a list of numbers, all rows the same length) and a vector whose length equals the number of columns, return the result vector: each output entry is the dot product of the corresponding matrix row with the vector. The matrix has at least one row. Return integer values where exact (do not round).
Implement
matvec(matrix: list[list[float]], vec: list[float]) → list[float]Examples
in
[[[1,0],[0,1]],[5,7]]out[5,7]What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 15 min
solution.py
InputExpectedGot
[[[1,0],[0,1]],[5,7]][5,7]not run yetsample