Тёмный

2491. Divide Players Into Teams of Equal Skill using Java | 04 Oct 2024 | Leetcode | Java | Array 

My Learning Hub
Подписаться 86
Просмотров 13
50% 1

LeetCode Problem of the day
4rt October 2024
Problem No [2491] : Divide Players Into Teams of Equal Skill using Java
Level : Medium
Topics : Hash Table | Array | Data Structure | Algorithm
------------------------------------------------
You may also explore my another playlists :
👉Java Tutorial :
• Java Tutorial | Java P...
👉 Geeks-for-Geeks Problem :
• Geeks-for-Geeks Problems
👉 Coding ninjas Easy coding problem :
• Coding Ninjas | MCQ Da...
----------------------------------------------------------------
⏩ Stay connected with me on social media for more updates and behind-the-scenes content !
You can find me on 🔍 :
📱Instagram Profile :
/ _ganesh_p09
🌐 LinkedIn Profile :
/ ganesh-prasad09
-----------------------------------------------------
✅ Description about the problem as follows :
You are given a positive integer array skill of even length n where skill[i] denotes the skill of the ith player. Divide the players into n / 2 teams of size 2 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 players on that team.
Return the sum of the chemistry of all the teams, or return -1 if there is no way to divide the players into teams such that the total skill of each team is equal.
Example 1:
Input: skill = [3,2,5,1,3,4]
Output: 22
Explanation:
Divide the players into the following teams: (1, 5), (2, 4), (3, 3), where each team has a total skill of 6.
The sum of the chemistry of all the teams is: 1 * 5 + 2 * 4 + 3 * 3 = 5 + 8 + 9 = 22.
Example 2:
Input: skill = [3,4]
Output: 12
Explanation:
The two players form a team with a total skill of 7.
The chemistry of the team is 3 * 4 = 12.
Example 3:
Input: skill = [1,1,2,3]
Output: -1
Explanation:
There is no way to divide the players into teams such that the total skill of each team is equal.
-----------------------------------------------------------
🔔 If you enjoyed the content, please subscribe to the channel for more updates! 📺
👍 If you found this video helpful, don't forget to give it a thumbs up and share it with your friends! 📤
🙏 Thank you for watching the video! 😊
--------------------------------------------------------
#leetcodesolution | DividePlayersIntoTeamsOfEqualSkill | #todaysolution | #array

Опубликовано:

 

14 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии    
Далее
Books every software engineer should read in 2024.
17:19
The Tesla Robotaxi is Confusing...
19:14
Просмотров 580 тыс.
Quicksort: Partitioning an array
4:48
Просмотров 585 тыс.
How I Mastered Data Structures and Algorithms
10:45
Просмотров 206 тыс.