class Solution:

    def maxOperations(self, nums: List[int], k: int) ->int:
        count = 0
        hashmap = collections.defaultdict(int)
        for n in nums:
            if hashmap[k - n]:
                hashmap[k - n] -= 1
                count += 1
            else:
                hashmap[n] += 1
        return count

84aee93b621caa19c09145addcf2da622949e131
<mask token>

class Solution:
    <mask token>

class Solution:

    def maxOperations(self, nums: List[int], k: int) ->int:
        count = 0
        hashmap = collections.defaultdict(int)
        for n in nums:
            if hashmap[k - n]:
                hashmap[k - n] -= 1
                count += 1
            else:
                hashmap[n] += 1
        return count
