Description
Solutions
Total Efficiency
📚RELATED PROBLEMS
A coding competition is being organized on the HackerRank platform. All participants need to be grouped into teams where each team has exactly two candidates and the sums of their skills must be equal for all teams. The efficiency of a team is the product of the skills of its members, e.g. for a team with skills [2, 3]
, the efficiency of the team is 2 * 3 = 6
.
Find the sum of the efficiencies of the teams. If there is no way to create teams that satisft the conditions, return -1
.
Notes
Function Description
Complete the function getTotalEfficiency
where has the following parameter:
int[] skills
: the skills of each candidateReturns
long
: the skills of each candidateExample 1:
Input: skill = [1, 2, 3, 2]
Output: 7
Explanation:The skills of the candidates are skill = [1, 2, 3, 2]. They can be paired as [[1, 3], [2, 2]]. The sum of skills for each team is the same, i.e., 4. The efficiency is computed as: Efficiency of [1, 3] = 1 * 3 = 3 Efficiency of [2, 2] = 2 * 2 = 4 Return the sume of efficiencies, 3 + 4 = 7.
Constraints:
N/A (If you know about it, feel free to contact us. TYVM!
Related Problems
Testcase
Result
Case 1
input:
output: