Identify High-Performing Teams
In large organizations, identifying and recognizing high-performing teams is crucial for fostering a culture of excellence and strategic resource allocation. This problem simulates a scenario where you need to analyze employee performance data to pinpoint teams that consistently exceed expectations based on both individual contributions and collective performance.
You are given a list of employee records, each containing an employee's ID, their team ID, and their individual performance score. Your task is to implement a function that identifies all unique team IDs corresponding to "high-performing" teams. A team is considered high-performing if it satisfies two specific criteria:
minQualifiedMembers employees whose individual performance_score is greater than or equal to minIndividualScoreThreshold.performance_score (sum of all members' scores divided by the total number of members) must be greater than or equal to minTeamAvgScoreThreshold.The function should return a list of these unique high-performing teamIds, sorted alphabetically.
Input:
employees: An array of objects, where each object represents an employee and has the following structure:
id: number (A unique identifier for the employee)teamId: string (The identifier for the team the employee belongs to)performanceScore: number (The employee's individual performance score, non-negative integer)minIndividualScoreThreshold: number (The minimum score an individual employee must achieve to be considered 'qualified' for the first criterion, non-negative integer)minQualifiedMembers: number (The minimum number of 'qualified' members a team must have to meet the first criterion, non-negative integer)minTeamAvgScoreThreshold: number (The minimum average performance score a team must achieve to meet the second criterion, non-negative integer)Output:
string[]: A list of unique teamIds that are identified as high-performing, sorted alphabetically.employees array should result in an empty list of high-performing teams.performanceScore values are guaranteed to be non-negative integers.minIndividualScoreThreshold, minQualifiedMembers, and minTeamAvgScoreThreshold are non-negative integers.Examples
Example 1
Input:
employees = [{id:1, teamId:'A', performanceScore:80}, {id:2, teamId:'B', performanceScore:90}, {id:3, teamId:'A', performanceScore:75}, {id:4, teamId:'C', performanceScore:60}, {id:5, teamId:'B', performanceScore:85}, {id:6, teamId:'A', performanceScore:95}, {id:7, teamId:'C', performanceScore:70}], minIndividualScoreThreshold = 80, minQualifiedMembers = 2, minTeamAvgScoreThreshold = 85
Output:
["B"]
Note:
Team A: Scores [80, 75, 95]. Qualified members (score >= 80): 2 (for 80, 95). Meets minQualifiedMembers (2 >= 2). Average score: (80+75+95)/3 = 83.33. Does NOT meet minTeamAvgScoreThreshold (83.33 < 85).
Team B: Scores [90, 85]. Qualified members (score >= 80): 2 (for 90, 85). Meets minQualifiedMembers (2 >= 2). Average score: (90+85)/2 = 87.5. Meets minTeamAvgScoreThreshold (87.5 >= 85). Team B is high-performing.
Team C: Scores [60, 70]. Qualified members (score >= 80): 0. Does NOT meet minQualifiedMembers (0 < 2).
Example 2
Input:
employees = [{id:1, teamId:'X', performanceScore:90}, {id:2, teamId:'Y', performanceScore:88}, {id:3, teamId:'X', performanceScore:92}, {id:4, teamId:'Y', performanceScore:85}, {id:5, teamId:'Z', performanceScore:95}, {id:6, teamId:'Z', performanceScore:90}], minIndividualScoreThreshold = 85, minQualifiedMembers = 2, minTeamAvgScoreThreshold = 87
Output:
["X", "Y", "Z"]
Note:
Team X: Scores [90, 92]. Qualified members (score >= 85): 2. Average: (90+92)/2 = 91. Both criteria met. Team Y: Scores [88, 85]. Qualified members (score >= 85): 2. Average: (88+85)/2 = 86.5. Both criteria met. Team Z: Scores [95, 90]. Qualified members (score >= 85): 2. Average: (95+90)/2 = 92.5. Both criteria met. All teams are high-performing. Output is sorted alphabetically.
Example 3
Input:
employees = [{id:1, teamId:'Alpha', performanceScore:70}, {id:2, teamId:'Beta', performanceScore:75}, {id:3, teamId:'Alpha', performanceScore:60}, {id:4, teamId:'Beta', performanceScore:65}], minIndividualScoreThreshold = 80, minQualifiedMembers = 1, minTeamAvgScoreThreshold = 70
Output:
[]
Note:
Team Alpha: Scores [70, 60]. Qualified members (score >= 80): 0. Does not meet minQualifiedMembers.
Team Beta: Scores [75, 65]. Qualified members (score >= 80): 0. Does not meet minQualifiedMembers.
No teams are high-performing.
Constraints
1 <= employees.length <= 10^51 <= employee.id <= 10^9 (unique)1 <= employee.teamId.length <= 100 <= employee.performanceScore <= 1000 <= minIndividualScoreThreshold <= 1000 <= minQualifiedMembers <= employees.length0 <= minTeamAvgScoreThreshold <= 100M will be between 1 and employees.length.Loading editor...