Code RoomIntent routing per-class correct
EasyPrep Room Coding #543

Intent routing per-class correct

CodingML systemsEntry–Mid~10 min

A chatbot routes each user message to one of several intents, numbered 0 to num_classes - 1. The eval dashboard shows, per intent, how many messages the model routed correctly. Given equal-length lists y_true and y_pred of intent ids and the integer num_classes, return a list of length num_classes where position c holds the count of messages with y_true[i] == c and y_pred[i] == c. All ids are valid (between 0 and num_classes - 1). Example: y_true = [0, 1, 2, 1], y_pred = [0, 2, 2, 1], num_classes = 3 gives [1, 1, 1].

Implement
correct_per_class(y_true: list[int], y_pred: list[int], num_classes: int) → list[int]
Examples
in[[0,1,2,1],[0,2,2,1],3]out[1,1,1]
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.

0:00 of about 10 min
InputExpectedGot
[[0,1,2,1],[0,2,2,1],3][1,1,1]not run yetsample