Problem · Array
Maximize Efficiency with TikTok
Learn this problemProblem statement
Given an integer array efficiencyScores, select exactly five elements and return the largest possible product of the selected values.
The five elements must come from distinct array positions. Their original order does not matter.
The function maximizeEfficiencyProduct receives efficiencyScores, the efficiency scores of the available tasks, and returns the maximum product as a long.
Function
maximizeEfficiencyProduct(efficiencyScores: int[]) → longExamples
Example 1
efficiencyScores = [6, 1, 2, 8, 1]return = 96There are exactly five values, so all of them must be selected. Their product is 96.
Constraints
5 <= efficiencyScores.length <= 10^5-10^3 <= efficiencyScores[i] <= 10^3