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

Question

A weekly bake-off scores several candidate models on eval sets of different sizes, so comparing them by floored percentages is too coarse. Given results, a non-empty list where results[i] = [correct_i, total_i] with total_i >= 1, return the index of the model with the highest exact accuracy correct_i / total_i. Compare two models with integer cross-multiplication: model i beats model j when correct_i * total_j > correct_j * total_i. If several models tie for best, return the smallest index. Example: results = [[45, 50], [90, 100], [8, 10]] returns 0 (0.9 ties 0.9, earlier index wins).

Implement
best_model(results: list[list[int]]) → int
Examples
in[[[45,50],[90,100],[8,10]]]out0
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.