Code Room
CodingEasycod-g1338
Subject Ml metricsLevel Entry–Mid~10 minCommon in ML systems · Algorithms & data structures interviewsIndustries Software development

Question

A churn model flags subscribers likely to cancel so the retention team can reach out. The team cares most about coverage: of the customers who actually churned, what share did the model flag? Given equal-length binary lists y_true and y_pred (1 = churned / flagged), let tp be positions where both are 1 and actual be the count of 1s in y_true. Return floor(100 * tp / actual). If no one actually churned (actual is 0), return -1. Example: y_true = [1, 0, 1, 1, 0], y_pred = [1, 0, 0, 1, 1] gives floor(200 / 3) = 66.

Implement
churn_recall(y_true: list[int], y_pred: list[int]) → int
Examples
in[[1,0,1,1,0],[1,0,0,1,1]]out66
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.