Code Room
CodingMediumcod-g1349
Subject Ml metricsLevel Entry–Mid~15 minCommon in ML systems interviewsIndustries Software development

Question

To check whether a churn model's confidence scores are calibrated, the eval groups predictions into ten confidence buckets and counts outcomes per bucket. Given equal-length lists scores (integers 0-100) and labels (0 or 1), assign each prediction to bucket floor(score / 10), except that a score of 100 goes into bucket 9. Return a list of exactly 10 rows, where row i is [count of predictions in bucket i, count of those with label 1]. Example: scores = [5, 95, 42, 100], labels = [0, 1, 1, 1] puts 5 in bucket 0, 42 in bucket 4, and 95 and 100 in bucket 9.

Implement
calibration_counts(scores: list[int], labels: list[int]) → list[list[int]]
Examples
in[[5,95,42,100],[0,1,1,1]]out[[1,0],[0,0],[0,0],[0,0],[1,1],[0,0],[0,0],[0,0],[0,0],[2,2]]
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.