Skip to content

Commit

Permalink
Added solution for Divide Players Into Teams of Equal Skill
Browse files Browse the repository at this point in the history
  • Loading branch information
Blacknahil committed Jan 3, 2024
1 parent f18afc9 commit 67cc0d2
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions week5/divide-players-into-teams-of-equal-skill.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class Solution:
def dividePlayers(self, skill: List[int]) -> int:
if len(skill)==2:
return skill[0] * skill[1]
left=0
right=len(skill)-1
skill.sort()
ans=0
_sum=skill[left] + skill[right]
while left<right:
if skill[left] + skill[right] !=_sum:
return -1
ans+=skill[left] * skill[right]
left+=1
right-=1
return ans


0 comments on commit 67cc0d2

Please sign in to comment.