Company: Fivetran
Difficulty: medium
Team Formation A company is picking a team of employees from a ranked evaluation list. You are given score , an array of n evaluation scores where score[i] is the score of the i -th employee, together with team_size and k . The team is built one member at a time by repeating the following, team_size times: Look at the first k employees still in the list and the last k employees still in the list. Among those employees, pick the one with the highest score. 2. Remove that employee from the list and add their score to the team's total. Two clarifications: If several of those employees are tied for the highest score, pick the one that appears earliest in the current list. If fewer than k employees remain in the list, the entire remaining list is considered for selection. Return the sum of the scores of all team_size selected employees. Example score = [10, 20, 10, 15, 5, 30, 20], team_size = 2, k = 3 First selection: first k employees: [10, 20, 10] last k employees: [5, 30, 20] the highest