java.lang.Object
g1601_1700.s1626_best_team_with_no_conflicts.Solution

public class Solution extends Object
1626 - Best Team With No Conflicts.<p>Medium</p> <p>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 <strong>sum</strong> of scores of all the players in the team.</p> <p>However, the basketball team is not allowed to have <strong>conflicts</strong>. A <strong>conflict</strong> exists if a younger player has a <strong>strictly higher</strong> score than an older player. A conflict does <strong>not</strong> occur between players of the same age.</p> <p>Given two lists, <code>scores</code> and <code>ages</code>, where each <code>scores[i]</code> and <code>ages[i]</code> represents the score and age of the <code>i<sup>th</sup></code> player, respectively, return <em>the highest overall score of all possible basketball teams</em>.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> scores = [1,3,5,10,15], ages = [1,2,3,4,5]</p> <p><strong>Output:</strong> 34</p> <p><strong>Explanation:</strong> You can choose all the players.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> scores = [4,5,6,5], ages = [2,1,2,1]</p> <p><strong>Output:</strong> 16</p> <p><strong>Explanation:</strong> It is best to choose the last 3 players. Notice that you are allowed to choose multiple people of the same age.</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> scores = [1,2,3,5], ages = [8,9,10,1]</p> <p><strong>Output:</strong> 6</p> <p><strong>Explanation:</strong> It is best to choose the first 3 players.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= scores.length, ages.length <= 1000</code></li> <li><code>scores.length == ages.length</code></li> <li><code>1 <= scores[i] <= 10<sup>6</sup></code></li> <li><code>1 <= ages[i] <= 1000</code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • bestTeamScore

      public int bestTeamScore(int[] scores, int[] ages)