The Modify the Matrix problem gives you a matrix where some entries contain -1. Replace each -1 with the maximum value in its column. This Modify the Matrix coding problem tests clean two-pass matrix traversal: first compute column maximums, then replace -1 entries.
Fidelity asks this easy-level problem to test array and matrix traversal skills under time pressure. It validates that candidates can perform a two-pass matrix operation correctly: gathering column-wise information in the first pass and applying it in the second. The array and matrix interview pattern is cleanly demonstrated.
Two-pass column scan. In the first pass, find the maximum value in each column (ignoring -1 values). In the second pass, replace any -1 entry with the precomputed maximum for that column.
Matrix:
1 -1 3
4 5 6
-1 2 9
Column maximums (ignoring -1): col 0 = max(1,4) = 4, col 1 = max(5,2) = 5, col 2 = max(3,6,9) = 9. After replacement:
1 5 3
4 5 6
4 2 9
Any matrix problem where "cells depend on their column's aggregate value" requires a two-pass approach. This is a clean example of the precompute-then-apply pattern. Internalize this structure: first pass gathers metadata (column max, row sum, etc.); second pass applies changes. This pattern extends to harder problems like "matrix with special values" and "set zeros in matrix."