arya2004 / leetcode-daily-october-hacktoberfest-2024

Leetcode Daily October Hacktoberfest 2024
MIT License
10 stars 49 forks source link

Create solution_javascript.js #43

Closed ssugam10 closed 1 month ago

ssugam10 commented 1 month ago

This is the solution to day 04 daily problem in october!

This code pairs up players based on their skill levels to form teams with equal total skill. It first sorts the skill levels, then checks if the sum of skills for each pair (one from the start and one from the end) matches the required sum (calculated from the first and last player's skill). If any pair doesn't match, it returns -1, indicating it's impossible to evenly divide the players. Otherwise, it calculates the total chemistry (product of paired players' skills) and returns it.