Skip to content
LC-2206 Easy LeetCode

2206. Divide Array Into Equal Pairs

Read the full problem statement on LeetCode.
Difficulty: easy Acceptance: 79% Topics: Array, Hash Table, Bit Manipulation, Counting
View full problem on LeetCode
Reference solution (spoiler · python)
# Time:  O(n)
# Space: O(n)

import collections


# freq table
class Solution(object):
    def divideArray(self, nums):
        """
        :type nums: List[int]
        :rtype: bool
        """
        return all(cnt%2 == 0 for cnt in collections.Counter(nums).itervalues())

Solution from kamyu104/LeetCode-Solutions · MIT