Question
Before trusting an accuracy number, your team checks how skewed the eval set is: a model that always answers 'not spam' looks great on a 99-to-1 dataset. Given a list of binary labels (0s and 1s), count each class and return floor(majority_count / minority_count) as an integer imbalance ratio. If the list is empty or only one class is present, return -1. Example: [0, 0, 0, 0, 1] has 4 zeros and 1 one, so return 4.
imbalance_ratio(labels: list[int]) → int[[0,0,0,0,1]]out4State 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.