Churn detection coverage

Write codeEasy10 minMeta and Spotify style

Your task

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.

Examples

churn_recall(y_true: list[int], y_pred: list[int]) -> int
Example 1
Inputchurn_recall([1, 0, 1, 1, 0], [1, 0, 0, 1, 1])
Output66