Question
A moderation model assigns each post one string category. For one target category, compute precision and recall scaled to integers. Given equal-length lists y_true and y_pred and a target category, let tp be positions where both equal target, predicted be positions where y_pred equals target, and actual be positions where y_true equals target. Return [floor(1000 * tp / predicted), floor(1000 * tp / actual)]. If predicted is 0 use -1 for the first value; if actual is 0 use -1 for the second. Example: y_true = ["toxic", "ok", "toxic", "spam"], y_pred = ["toxic", "toxic", "ok", "spam"], target "toxic" gives [500, 500].
class_prec_recall(y_true: list[str], y_pred: list[str], target: str) → list[int][["toxic","ok","toxic","spam"],["toxic","toxic","ok","spam"],"toxic"]out[500,500]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.