Tap here to switch tabs
Problem
Submissions

Problem: Divide Players Into Teams of Equal Skill

med
30 min
Try to solve the Divide Players Into Teams of Equal Skill problem.

Statement

You are given a positive integer array skill of even length nn, where skill[i] represents the skill level of the iextthi^{ ext{th}} player.

Divide the players into n/2n / 2 teams of size 22 such that the total skill of each team is equal.

The chemistry of a team is equal to the product of the skills of the two players on that team.

Return the sum of the chemistry of all teams, or return −1-1 if it is impossible to divide the players into teams such that each team has equal total skill.

Constraints:

  • 2≤2 \leq skill.length ≤105\leq 10^5

  • skill.length is even.

  • 1≤1 \leq skill[i] ≤1000\leq 1000

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Divide Players Into Teams of Equal Skill

med
30 min
Try to solve the Divide Players Into Teams of Equal Skill problem.

Statement

You are given a positive integer array skill of even length nn, where skill[i] represents the skill level of the iextthi^{ ext{th}} player.

Divide the players into n/2n / 2 teams of size 22 such that the total skill of each team is equal.

The chemistry of a team is equal to the product of the skills of the two players on that team.

Return the sum of the chemistry of all teams, or return −1-1 if it is impossible to divide the players into teams such that each team has equal total skill.

Constraints:

  • 2≤2 \leq skill.length ≤105\leq 10^5

  • skill.length is even.

  • 1≤1 \leq skill[i] ≤1000\leq 1000