Leetcode Note: Go - Divide Array Into Equal Pairs
Divide Array Into Equal Pairs - LeetCode
https://leetcode.com/problems/divide-array-into-equal-pairs/
- Go 言語で取り組んだメモ
回答
[GO] 90 % Faster Solution| | SPEED: 10 ms || MEMORY: 4.1 mb | | - Divide Array Into Equal Pairs - LeetCode
https://leetcode.com/problems/divide-array-into-equal-pairs/solutions/2307709/go-90-faster-solution-speed-10-ms-memory-4-1-mb/
func divideArray(nums []int)(bool) {
sort.Ints(nums)
res := true
for i := 0 ; i < len(nums); i+=2{
if nums[i]!=nums[i+1] {
return false
}
}
return res
}