Code RoomConfusion matrix cells
EasyPrep Room Coding #523

Confusion matrix cells

CodingML systemsAlgorithms & data structuresEntry–Mid~10 min

Your team ships a spam filter and the eval dashboard needs the four confusion-matrix cells. Given two equal-length lists of binary labels, y_true and y_pred (1 = spam, 0 = not spam), return the list [tp, fp, fn, tn] where tp counts pairs with true 1 and predicted 1, fp counts true 0 predicted 1, fn counts true 1 predicted 0, and tn counts true 0 predicted 0. Example: y_true = [1, 0, 1, 1, 0], y_pred = [1, 1, 0, 1, 0] gives [2, 1, 1, 1].

Implement
confusion_cells(y_true: list[int], y_pred: list[int]) → list[int]
Examples
in[[1,0,1,1,0],[1,1,0,1,0]]out[2,1,1,1]
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 10 min
InputExpectedGot
[[1,0,1,1,0],[1,1,0,1,0]][2,1,1,1]not run yetsample