Team Formation
Updated
Problem statement
Given a list of employees where each is assigned a numeric evaluation score, use the selection process below to find the sum of scores of selected employees.
- The employee with the highest score among the first
kemployees or the lastkemployees in the score list is selected. - The selected employee is removed from the score list.
- The process continues to select the next employee until the
team_sizeis achieved.
Note:
- In case multiple employees have the same highest score, the employee with the lowest index is selected.
- If there are fewer than
kemployees, the entire list is available for selection.
Function
teamFormation(score: int[], team_size: int, k: int) → int
Complete the function teamFormation in the editor.
teamFormation has the following parameter(s):
score[n]: an array of scores for each employeeteam_size: the number of team members requiredk: the size of the array segments to select from
Examples
Example 1
score = [10, 20, 10, 15, 5, 30, 20]team_size = 2k = 3return = 50For the first selection, choose from the first 3 elements: [10, 20, 10] or the last 3 elements: [5, 30, 20]. Score 30 is selected and removed from the list. This makes score = [10, 20, 10, 15, 5, 20].
For the second selection, choose from [10, 20, 10] or [15, 5, 20]. Score 20 is selected from the lowest index and removed from the list. This makes score = [10, 10, 15, 5, 20].
The sum of the selected employees' scores is 30 + 20 = 50.
Constraints
🥝🥝
More DoorDash interview questions
- Random Dasher Set OperationsONSITE INTERVIEW · Seen Nov 2026
- Customer Bootstrap APIPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Dasher Pay with Store Waits and Peak HoursPHONE SCREEN · Seen Nov 2026
- Simulate an Idempotent Refund Service FlowONSITE INTERVIEW · Seen Sep 2026
- Dasher Active TimePHONE SCREEN · Seen Sep 2026
- First Unique ID in a StreamONSITE INTERVIEW · Seen Aug 2026
- Minimum Parenthesis Removals and Their IndicesONSITE INTERVIEW · Seen Aug 2026
- Minimum Processing Speed with Multiple RidersONSITE INTERVIEW · Seen Aug 2026
- Minimum Single-Rider Processing SpeedONSITE INTERVIEW · Seen Aug 2026
- Merchant Capacity Interval MergePHONE SCREEN · Seen Aug 2026
Similar questions at other companies
- Minimum Cost to Merge Values into OnePayPal · OAPayPal interview questions
- Top K Frequent ElementsAmazon · OA · PHONE SCREEN
- Maximum ScoreNVIDIA · OANVIDIA interview questions
- Minimum Meeting RoomsJP Morgan Chase · OAJP Morgan Chase interview questions
- Maximize Revenue from Decreasing InventoryChubb · OAChubb interview questions
- Meeting Rooms IIWise · OA
- Rearrange Songs by AuthorZomato / Eternal · OAZomato / Eternal interview questions
- Auction Sniping Window MinimumCisco · OACisco interview questions
- Minimize the Sum with Ceiling HalvesSquarepoint Capital · OASquarepoint Capital interview questions
- Effective ManagerGoldman Sachs · OAGoldman Sachs interview questions
DoorDash interview experiences
- DoorDash SWE Onsite: Donation System Design: 1 Experience
- DoorDash SWE Phone Screen: Bootstrap API in Java: 1 Experience
- DoorDash SWE Virtual Onsite: 1 Experience
- DoorDash SWE Phone Screen: Bootstrap API Parsing: 1 Experience
- DoorDash Senior SWE Onsite Interview Experience: 1 Experience
- DoorDash AI CodeCraft Interview: 8 Experiences