Customer Support: email@example.com
We are listening to your every feedback,
and taking action to constantly improve your learning experience.
If you have any feedback, please use this form:
Problem Statement: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.
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.
Given two lists, scores and ages, where each scores[i] and ages[i] represents the score and age of the ith player, respectively, return the highest overall score of all possible basketball teams.
Input: scores = [1,3,5,10,15], ages = [1,2,3,4,5]
Explanation: You can choose all the players.
Input: scores = [4,5,6,5], ages = [2,1,2,1]
Explanation: It is best to choose the last 3 players. Notice that you are allowed to choose multiple people of the same age.
Input: scores = [1,2,3,5], ages = [8,9,10,1]
Explanation: It is best to choose the first 3 players.
This problem is a great example of how Longest Increasing Subsequence could be used to solve real-world problems. I have put all the key points as inline comments in the code below. Let's take a look.
This is a Premium content.
Please subscribe to Algorithms course to access the code.
Other related chapters:
- Core Concept
- Box Stacking
- Russian Doll Envelopes
- Largest Divisible Subset
- Longest String Chain
- Longest Bitonic Subsequence
The above content is written by:
If you have any feedback, please use this form: https://thealgorists.com/Feedback.
Follow Us On LinkedIn