Best Team With No Conflicts
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
Player i has score scores[i] and age ages[i]. You want to pick a team (any subset of players) with the largest total score.
A team has a conflict if it includes a younger player whose score is **strictly greater** than the score of an older player. Players of the same age never conflict with each other, whatever their scores.
Return the highest total score of a conflict-free team. O(n^2) is acceptable.
Examples
Constraints
- 1 <= scores.length, ages.length <= 1000
- scores.length == ages.length
- 1 <= scores[i] <= 10^6
- 1 <= ages[i] <= 1000
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.