Code Room
CodingEasycod-g988
Subject Machine learningLevel Entry–Mid~15 minCommon in ML systems · Algorithms & data structures interviewsIndustries Software development, Technology

Question

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.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.