Hardware interview practice
Verify matrix zero propagation
Implement a two-pass predictor and two-entry tagged scoreboard for a matrix sanitizer that zeroes every row and column containing an original zero without cascading from newly written zeroes.
Reviewed example
Work through one case
Input
matrix=[[1,2,0],[4,5,6]]Expected output
sanitized=[[0,0,0],[4,5,0]]Only original row 0 and original column 2 are marked; zeroes written during transformation do not cascade into row 1.
What to cover
Requirements
- Deep-copy each accepted matrix and derive row and column masks exclusively from the untouched original snapshot.
- Match up to two outstanding responses by ID, compare every coordinate, and diagnose the first mismatch with the original matrix and both masks.
- Reject duplicate or unknown responses and flush accepted work on reset.
- Explain why no-zero, single-zero, intersecting, edge, full-row, full-column, all-zero, and non-square cases are useful follow-up tests.
