2206.js
/** ------------------------------------------------------------------------------
*
* 2206. Divide Array Into Equal Pairs
* Topics: Array, Hash Table
* https://leetcode.com/problems/divide-array-into-equal-pairs/description/?envType=daily-question&envId=2025-03-17
*
------------------------------------------------------------------------------ */
/**
* @param {number[]} nums
* @return {boolean}
*/
const divideArray = function (nums) {
const hash = {}
for (let n of nums) {
hash[n] = (hash[n] || 0) + 1
}
for (const key in hash) {
if (hash[key] % 2 !== 0) {
return false
}
}
return true
}
console.log(divideArray([3, 2, 3, 2, 2, 2]))