URL: https://leetcode.com/problems/divide-array-into-equal-pairs/ Signed-off-by: Matej Focko <me@mfocko.xyz>
19 lines
259 B
Go
19 lines
259 B
Go
package main
|
|
|
|
import (
|
|
hs "github.com/emirpasic/gods/v2/sets/hashset"
|
|
)
|
|
|
|
func divideArray(nums []int) bool {
|
|
seen := hs.New[int]()
|
|
|
|
for _, x := range nums {
|
|
if seen.Contains(x) {
|
|
seen.Remove(x)
|
|
} else {
|
|
seen.Add(x)
|
|
}
|
|
}
|
|
|
|
return seen.Empty()
|
|
}
|