Skip to content
LC-2410 Medium LeetCode

2410. Maximum Matching of Players With Trainers

Read the full problem statement on LeetCode.
Difficulty: medium Acceptance: 67% Topics: Array, Two Pointers, Greedy, Sorting
View full problem on LeetCode
Reference solution (spoiler · python)
# Time:  O(nlogn + mlogm)
# Space: O(1)

# greedy, sort
class Solution(object):
    def matchPlayersAndTrainers(self, players, trainers):
        """
        :type players: List[int]
        :type trainers: List[int]
        :rtype: int
        """
        players.sort()
        trainers.sort()
        result = 0
        for x in trainers:
            if players[result] > x:
                continue
            result += 1
            if result == len(players):
                break
        return result

Solution from kamyu104/LeetCode-Solutions · MIT