Code Room
CodingEasycod-g1355
Subject Ml metricsLevel Entry–Mid~10 minCommon in ML systems interviewsIndustries Software development

Question

A churn model predicts each customer's remaining subscription length in days, and the product team considers a prediction 'good enough' when it lands within a tolerance of the actual value. Given non-empty equal-length integer lists y_true and y_pred and a non-negative integer tolerance, return the number of positions where the absolute difference |y_true[i] - y_pred[i]| is less than or equal to tolerance. Example: y_true = [30, 60, 10], y_pred = [35, 80, 10], tolerance = 5 returns 2.

Implement
within_tolerance(y_true: list[int], y_pred: list[int], tolerance: int) → int
Examples
in[[30,60,10],[35,80,10],5]out2
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.