Tap here to switch tabs
Problem
Submissions

Problem: Reward Top K Students

med
30 min
Try to solve the Reward Top K Students problem.

Statement

You are given two string arrays positive_feedback and negative_feedback, containing positive and negative words respectively. You are also given two arrays report and student_id, where report[i] is a report describing the student with ID student_id[i], and an integer k.

Each student initially has 00 points. The points of a student are determined by the words in their corresponding report[i]:

  • Every occurrence of a word from positive_feedback increases the score by 33 points.

  • Every occurrence of a word from negative_feedback decreases the score by 11 point.

Return the IDs of the top k students sorted in descending order of their total score. If two students have the same score, the student with the smaller student_id ranks higher.

Constraints:

  • 1≤1 \leq positive_feedback.length, negative_feedback.length ≤104\leq 10^4

  • 1≤1 \leq positive_feedback[i].length, negative_feedback[j].length ≤100\leq 100

  • Both positive_feedback[i] and negative_feedback[j] consist of lowercase English letters.

  • No word is present in both positive_feedback and negative_feedback.

  • n ==== report.length ==== student_id.length

  • 1≤n≤1041 \leq n \leq 10^4

  • report[i] consists of lowercase English letters and spaces ' '.

  • There is a single space between consecutive words of report[i].

  • 1≤1 \leq report[i].length ≤100\leq 100

  • 1≤1 \leq student_id[i] ≤109\leq 10^9

  • All the values of student_id[i] are unique.

  • 1≤k≤n1 \leq k \leq n

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Reward Top K Students

med
30 min
Try to solve the Reward Top K Students problem.

Statement

You are given two string arrays positive_feedback and negative_feedback, containing positive and negative words respectively. You are also given two arrays report and student_id, where report[i] is a report describing the student with ID student_id[i], and an integer k.

Each student initially has 00 points. The points of a student are determined by the words in their corresponding report[i]:

  • Every occurrence of a word from positive_feedback increases the score by 33 points.

  • Every occurrence of a word from negative_feedback decreases the score by 11 point.

Return the IDs of the top k students sorted in descending order of their total score. If two students have the same score, the student with the smaller student_id ranks higher.

Constraints:

  • 1≤1 \leq positive_feedback.length, negative_feedback.length ≤104\leq 10^4

  • 1≤1 \leq positive_feedback[i].length, negative_feedback[j].length ≤100\leq 100

  • Both positive_feedback[i] and negative_feedback[j] consist of lowercase English letters.

  • No word is present in both positive_feedback and negative_feedback.

  • n ==== report.length ==== student_id.length

  • 1≤n≤1041 \leq n \leq 10^4

  • report[i] consists of lowercase English letters and spaces ' '.

  • There is a single space between consecutive words of report[i].

  • 1≤1 \leq report[i].length ≤100\leq 100

  • 1≤1 \leq student_id[i] ≤109\leq 10^9

  • All the values of student_id[i] are unique.

  • 1≤k≤n1 \leq k \leq n