This commit is contained in:
parent
fb11ede9a9
commit
c896dc5903
1 changed files with 14 additions and 0 deletions
14
easy/divide_array_into_equal_pairs.py
Normal file
14
easy/divide_array_into_equal_pairs.py
Normal file
|
|
@ -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))
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue