From c896dc5903349001ce6c2ca2e82bfb7f27e40712 Mon Sep 17 00:00:00 2001 From: bumpsoo Date: Mon, 17 Mar 2025 13:23:19 +0000 Subject: [PATCH] https://leetcode.com/problems/divide-array-into-equal-pairs --- easy/divide_array_into_equal_pairs.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 easy/divide_array_into_equal_pairs.py diff --git a/easy/divide_array_into_equal_pairs.py b/easy/divide_array_into_equal_pairs.py new file mode 100644 index 0000000..0e04d6b --- /dev/null +++ b/easy/divide_array_into_equal_pairs.py @@ -0,0 +1,14 @@ +# https://leetcode.com/problems/divide-array-into-equal-pairs + +from typing import List, Set + +class Solution: + def divideArray(self, nums: List[int]) -> bool: + s: Set[int] = set() + for num in nums: + if num in s: + s.remove(num) + else: + s.add(num) + return not bool(len(s)) +