Efficient Teams
Updated
Problem statement
Candidates in a coding contest must be split into teams of exactly two. The array skill gives each candidate's skill level, and everyone must be on a team.
All teams must have the same total skill. The efficiency of a team is the product of its two skill levels.
Return the sum of the efficiencies of all the teams. If the teams cannot be formed, return -1.
When the teams can be formed, this sum is the same for every valid way of forming them, so there is only one correct answer.
Function
getTotalEfficiency(skill: int[]) → longExamples
Example 1
skill = [1,2,3,2]return = 7The total skill is 8, and there are 2 teams, so each team must sum to 4. The teams are [1, 3] and [2, 2].
Their efficiencies are 1 * 3 = 3 and 2 * 2 = 4, so the answer is 3 + 4 = 7.
Example 2
skill = [5,4,2,1]return = 13Each team must sum to 6. The teams are [1, 5] and [4, 2].
Their efficiencies are 1 * 5 = 5 and 4 * 2 = 8, so the answer is 5 + 8 = 13.
Example 3
skill = [2,1,1,4,3,5]return = -1The total skill is 16, and there are 3 teams. 16 does not divide evenly by 3, so the teams cannot all have the same sum. The answer is -1.
Constraints
2 <= skill.length <= 10^5skill.lengthis even.1 <= skill[i] <= 10^5
More Expedia Online Assessment questions
- Balanced NumbersOA · Seen Aug 2026
- REST API: Discounted PriceOA · Seen Aug 2026
- Maximum Team SizeOA · Seen Mar 2026
- Per-Domain Request LimiterOA · Seen Oct 2025
- Count Equal-Frequency SubsequencesOA · Seen Mar 2025
- Count Increasing Stock PeriodsOA · Seen Mar 2025
- Get Minimum StepsOA · Seen Oct 2024
- Rank Songs by PopularityOA · Seen Oct 2024
- Calculate the SumOA · Seen Oct 2024
- Get Maximum EfficiencyOA · Seen Oct 2024
Similar questions at other companies
- Count Cross-Array Target-Sum PairsVisa · OAVisa interview questions
- Disjoint Target-Sum TripletsAmerican Express · PHONE SCREENAmerican Express interview questions
- Two SumMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Count Servers With No Requests in a Time WindowIBM · OAIBM interview questions
- Minimum Distinct Prefix CostChubb · OAChubb interview questions
- Top K Frequent ElementsAmazon · OA · PHONE SCREEN
- Minimum Distinct Prefix CostGoldman Sachs · OAGoldman Sachs interview questions
- Latest Arrival to Catch a BusAutodesk · OAAutodesk interview questions
- Convert Sparse Records to a Filled TableNetflix · OANetflix interview questions
- Minimum Removals to Balance ArraySalesforce · OASalesforce interview questions
Expedia interview experiences
- Expedia Intern Final Round in 2021: 28 Experiences (Part 4 of 6)
- Expedia Intern Finals Before 2020: 14 Experiences (Part 6 of 6)
- Expedia Intern Final Round in 2020: 24 Experiences (Part 5 of 6)
- Expedia Intern Final Round in 2022: 15 Experiences (Part 3 of 6)
- Expedia Intern Final Round in 2023: 17 Experiences (Part 2 of 6)
- Expedia SWE Intern Final Round: 126 Experiences (Part 1 of 6)