- Efficient Teams A coding competition is being organized on the HackerRank platform. The participants need to be grouped into teams where each team has exactly two candidates. There are n candidates, where each candidate has a skill denoted by skill[i]. A total of ( n/2) teams are to be formed, such that the total skill of each team is the same. The efficiency of a team is defined as the product of the skill levels of its two members, i.e., for the-skills [1, 3], the efficiency of the team is 1∗3=3. Find the sum of efficiencies of all teams that can be formed satisfying the criteria. If there is no way to create teams that satisfy the conditions, return −1. Note: It can be shown that the answer is always unique. Example 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, l.e., 4. The efficiency is computed as: - Efficiency of [1,3]=1∗3=3 - Efficiency of [2,2]=2∗2=4 Return the sum of efficiencies, 3+4=7. Function Description Complete the function getTotalEfficiency in the editor below. getTotalEfficiency has the followino naramatam. Function Desaription Complete the function getTotalEfificiengy in the editor below. getTotalEfficiency has the following parameter: int skill[n]: the skill of each candidate Returns long int: the sum of the efficiencies Constraints −1≤n≤105 - 1≤ skilli0m 105 - n is even. - It is guaranteed that the answer is unique. Input Format For Custom Testing - Sample Case 0 Sample Input For Custom Testing Sample output 13 Explanation Form teams as [1,5],[4,2]. The sums of each pair are 6 . Returns long int: the sum of the efficiencies Constraints - 1≤n≤105 - 1≤skili[]≤105 - n is even. - It is guaranteed that the answer is unique. Input Format For Custom Testing Vample Case 0 Sample Input For Custom Testing STDIN 45421​→​ FUNCTION − skill[] size, n skill =[5,4,​​ Sample Output 13 Explanation Form teams as [11,5],[4,2]. The sums of each pair are 6. The efficiency is computed as: - Efficiency of [1,5]=1∗5=5 - Efficiency of [4,2]=4∗2=8 Sample Case 1 # Complete the 'getTotalefficiency' function below. # # The function is expected to return a LONG_INTEGER. # The function accepts INTEGER_ARRAY skill as parameter. # 8 def getTotalefficiency(skill): 19 # Write your code here 21> if __name == '__main__' 20⋅…



Answer :

Other Questions