Trains the technique from
LeetCode 2512Reward Top K StudentsThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A workshop scores its reviewers on the notes they leave. positive_feedback lists the words counted as praise and negative_feedback lists the words counted as criticism. No word appears in both lists.
report[i] is the note left by the reviewer whose badge number is student_id[i]. A note is lowercase words separated by single spaces. Scoring a note starts at zero, adds 3 for each word of the note that appears in the praise list, and subtracts 1 for each word that appears in the criticism list. A word only counts when it matches a listed word exactly; a listed word appearing inside a longer word does not count. A word counts once for each time it appears in the note.
Rank the reviewers by score, highest first, and settle a tie in favour of the smaller badge number. Return the badge numbers of the top k reviewers, in that ranked order.
Example 1
Badge 42 leaves two praise words for a score of 6. Badge 19 leaves none of either, scoring 0. Badge 7 leaves two criticism words, scoring -2. The top two in that order are 42 then 19.
Example 2
Both reviewers score 3. The tie is settled in favour of the smaller badge number, so badge 4 is ranked ahead of badge 9.
Example 3
The word "neatly" is not the listed word "neat", so badge 3 scores 0 while badge 8 scores 3.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def top_reviewers(positive_feedback: list[str], negative_feedback: list[str], report: list[str], student_id: list[int], k: int) -> list[int]:public List<Integer> topReviewers(String[] positiveFeedback, String[] negativeFeedback, String[] report, int[] studentId, int k)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.