go: add «2206. Divide Array Into Equal Pairs»
URL: https://leetcode.com/problems/divide-array-into-equal-pairs/ Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
parent
6cda50188b
commit
aec179520a
1 changed files with 19 additions and 0 deletions
19
go/divide-array-into-equal-pairs.go
Normal file
19
go/divide-array-into-equal-pairs.go
Normal file
|
@ -0,0 +1,19 @@
|
|||
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()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue