Code RoomChurn detection coverage
EasyPrep Room Coding #526

Churn detection coverage

CodingML systemsAlgorithms & data structuresEntry–Mid~10 min

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.

0:00 of about 10 min
InputExpectedGot
[[1,0,1,1,0],[1,0,0,1,1]]66not run yetsample