2512. Reward Top K Students Medium
1/**
2 * [2512] Reward Top K Students
3 *
4 * You are given two string arrays positive_feedback and negative_feedback, containing the words denoting positive and negative feedback, respectively. Note that no word is both positive and negative.
5 * Initially every student has 0 points. Each positive word in a feedback report increases the points of a student by 3, whereas each negative word decreases the points by 1.
6 * You are given n feedback reports, represented by a 0-indexed string array report and a 0-indexed integer array student_id, where student_id[i] represents the ID of the student who has received the feedback report report[i]. The ID of each student is unique.
7 * Given an integer k, return the top k students after ranking them in non-increasing order by their points. In case more than one student has the same points, the one with the lower ID ranks higher.
8 *
9 * <strong class="example">Example 1:
10 *
11 * Input: positive_feedback = ["smart","brilliant","studious"], negative_feedback = ["not"], report = ["this student is studious","the student is smart"], student_id = [1,2], k = 2
12 * Output: [1,2]
13 * Explanation:
14 * Both the students have 1 positive feedback and 3 points but since student 1 has a lower ID he ranks higher.
15 *
16 * <strong class="example">Example 2:
17 *
18 * Input: positive_feedback = ["smart","brilliant","studious"], negative_feedback = ["not"], report = ["this student is not studious","the student is smart"], student_id = [1,2], k = 2
19 * Output: [2,1]
20 * Explanation:
21 * - The student with ID 1 has 1 positive feedback and 1 negative feedback, so he has 3-1=2 points.
22 * - The student with ID 2 has 1 positive feedback, so he has 3 points.
23 * Since student 2 has more points, [2,1] is returned.
24 *
25 *
26 * Constraints:
27 *
28 * 1 <= positive_feedback.length, negative_feedback.length <= 10^4
29 * 1 <= positive_feedback[i].length, negative_feedback[j].length <= 100
30 * Both positive_feedback[i] and negative_feedback[j] consists of lowercase English letters.
31 * No word is present in both positive_feedback and negative_feedback.
32 * n == report.length == student_id.length
33 * 1 <= n <= 10^4
34 * report[i] consists of lowercase English letters and spaces ' '.
35 * There is a single space between consecutive words of report[i].
36 * 1 <= report[i].length <= 100
37 * 1 <= student_id[i] <= 10^9
38 * All the values of student_id[i] are unique.
39 * 1 <= k <= n
40 *
41 */
42pub struct Solution {}
43
44// problem: https://leetcode.com/problems/reward-top-k-students/
45// discuss: https://leetcode.com/problems/reward-top-k-students/discuss/?currentPage=1&orderBy=most_votes&query=
46
47// submission codes start here
48
49impl Solution {
50 pub fn top_students(positive_feedback: Vec<String>, negative_feedback: Vec<String>, report: Vec<String>, student_id: Vec<i32>, k: i32) -> Vec<i32> {
51 vec![]
52 }
53}
54
55// submission codes end
56
57#[cfg(test)]
58mod tests {
59 use super::*;
60
61 #[test]
62 fn test_2512() {
63 }
64}
65
Back
© 2025 bowen.ge All Rights Reserved.