1626. Best Team With No Conflicts Medium

@problem@discussion
#Array#Dynamic Programming#Sorting



1/**
2 * [1626] Best Team With No Conflicts
3 *
4 * You are the manager of a basketball team. For the upcoming tournament, you want to choose the team with the highest overall score. The score of the team is the sum of scores of all the players in the team.
5 * However, the basketball team is not allowed to have conflicts. A conflict exists if a younger player has a strictly higher score than an older player. A conflict does not occur between players of the same age.
6 * Given two lists, scores and ages, where each scores[i] and ages[i] represents the score and age of the i^th player, respectively, return the highest overall score of all possible basketball teams.
7 *  
8 * Example 1:
9 * 
10 * Input: scores = [1,3,5,10,15], ages = [1,2,3,4,5]
11 * Output: 34
12 * Explanation: You can choose all the players.
13 * 
14 * Example 2:
15 * 
16 * Input: scores = [4,5,6,5], ages = [2,1,2,1]
17 * Output: 16
18 * Explanation: It is best to choose the last 3 players. Notice that you are allowed to choose multiple people of the same age.
19 * 
20 * Example 3:
21 * 
22 * Input: scores = [1,2,3,5], ages = [8,9,10,1]
23 * Output: 6
24 * Explanation: It is best to choose the first 3 players. 
25 * 
26 *  
27 * Constraints:
28 * 
29 * 	1 <= scores.length, ages.length <= 1000
30 * 	scores.length == ages.length
31 * 	1 <= scores[i] <= 10^6
32 * 	1 <= ages[i] <= 1000
33 * 
34 */
35pub struct Solution {}
36
37// problem: https://leetcode.com/problems/best-team-with-no-conflicts/
38// discuss: https://leetcode.com/problems/best-team-with-no-conflicts/discuss/?currentPage=1&orderBy=most_votes&query=
39
40// submission codes start here
41
42impl Solution {
43    pub fn best_team_score(scores: Vec<i32>, ages: Vec<i32>) -> i32 {
44        0
45    }
46}
47
48// submission codes end
49
50#[cfg(test)]
51mod tests {
52    use super::*;
53
54    #[test]
55    fn test_1626() {
56    }
57}
58


Back
© 2025 bowen.ge All Rights Reserved.