diff --git "a/leetcode3/\355\231\251\354\235\200\354\247\200/914. X of a Kind in a Deck of Cards.js" "b/leetcode3/\355\231\251\354\235\200\354\247\200/914. X of a Kind in a Deck of Cards.js" new file mode 100644 index 00000000..b8544acb --- /dev/null +++ "b/leetcode3/\355\231\251\354\235\200\354\247\200/914. X of a Kind in a Deck of Cards.js" @@ -0,0 +1,27 @@ +/** + * @param {number[]} deck + * @return {boolean} + */ +var hasGroupsSizeX = function(deck) { + if(deck.length===1) return false; + + const numCount = {}; + for (const num of deck) { + numCount[num] = (numCount[num] || 0) + 1; + } + + const counts = Object.values(numCount); + + let totalGcd=counts[0]; + + const gcd=(a,b)=>{ + return b===0? a:gcd(b,a%b); + } + + for(let i=1;i=2 +}; \ No newline at end of file