Problem · Array
Total Efficiency
Learn this problemProblem statement
Given an even-length array skill, assign every participant to a two-person team.
A grouping is valid only when every team has the same total skill. The efficiency of a team is the product of its two skill values.
Return the sum of all team efficiencies. If no valid grouping exists, return -1.
Function
getTotalEfficiency(skill: int[]) → longExamples
Example 1
skill = [1, 2, 3, 2]return = 7Pair the values as [1, 3] and [2, 2]. Both teams have total skill 4. Their efficiencies are 3 and 4, so the result is 7.
Constraints
2 ≤ skill.length ≤ 2 × 10^5skill.lengthis even.1 ≤ skill[i] ≤ 10^9
More IBM problems
- Parent Process NumberOA · Seen Jul 2026
- Request Retry CountOA · Seen Jul 2026
- Count Strictly Increasing Subsequences of Length 3OA · Seen Jul 2026
- Maximum Requests in a Time WindowOA · Seen Jul 2026
- Query Type Frequency WindowOA · Seen Jul 2026
- Minimum Number of Non-Empty Disjoint SegmentsOA · Seen Jul 2026
- Spam Text ClassificationOA · Seen Jul 2026
- Count Ideal NumbersOA · Seen Jun 2026