Top-k violations count
Your task
A moderation model ranks the day's flagged posts from most to least suspicious, and human reviewers only get through the first k. To judge whether the top of the queue is worth their time, count the real violations there. Given ranked_labels, a list ordered by the model's ranking where 1 means the post truly violated policy and 0 means it did not, and an integer k >= 0, return the number of 1s among the first k entries. If k exceeds the list length, use the whole list. Example: ranked_labels = [1, 0, 1, 1, 0], k = 3 returns 2.
Examples
hits_in_review_budget(ranked_labels: list[int], k: int) -> intExample 1
Input
hits_in_review_budget([1, 0, 1, 1, 0], 3)Output
2