Question
A model's headline accuracy can hide a slice that is quietly failing. Each eval example has a group key (like a locale or device type). Given equal-length lists groups (strings), y_true, and y_pred (integers), compute each group's accuracy correct/total and return the name of the group with the lowest accuracy. Compare two groups' accuracies exactly using cross-multiplication: correct_1 * total_2 versus correct_2 * total_1. If several groups tie for lowest, return the alphabetically smallest name. Input is non-empty. Example: groups = ["us", "us", "eu", "eu"], y_true = [1, 0, 1, 0], y_pred = [1, 0, 0, 0] gives "eu".
weakest_slice(groups: list[str], y_true: list[int], y_pred: list[int]) → str[["us","us","eu","eu"],[1,0,1,0],[1,0,0,0]]out"eu"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.