Imagine you're building a student evaluation system for a coding bootcamp! ๐
You have feedback reports from instructors about students, and you need to automatically rank students based on their performance to reward the top performers.
Here's how the scoring works:
- Each
positive wordin a feedback report gives +3 points - Each
negative wordin a feedback report gives -1 point - Students start with 0 points
Your task: Given feedback reports and student IDs, return the top K students ranked by their total points. If students have the same points, the one with the lower student ID ranks higher.
Input: Arrays of positive/negative words, feedback reports, student IDs, and K
Output: Array of top K student IDs in descending order by points
Input & Output
Time & Space Complexity
n reports ร m words for scoring + s students ร log(s) for sorting
p positive/negative words in hash sets + s students in score map
Constraints
- 1 โค positive_feedback.length, negative_feedback.length โค 104
- 1 โค positive_feedback[i].length, negative_feedback[i].length โค 100
- 1 โค report.length โค 104
- 1 โค report[i].length โค 100
- 1 โค student_id.length โค 104
- 1 โค k โค student_id.length
- No word appears in both positive_feedback and negative_feedback
- All strings consist of lowercase English letters and spaces
- Each student_id[i] is unique