2341. Maximum Number of Pairs in Array

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 2341

class Solution:
    def numberOfPairs(self, nums: List[int]) -> List[int]:
        cnt = Counter(nums)
        s = sum(v // 2 for v in cnt.values())
        return [s, len(nums) - s * 2]