1// X of a Kind in a Deck of Cards2// Leetcode problem : https://leetcode.com/problems/x-of-a-kind-in-a-deck-of-cards/34class Solution {5public boolean hasGroupsSizeX(int[] deck) {6int[] count = new int[10000];7for (int i : deck) count[i]++;8int gcd = 0;9for (int i : count) if (i != 0) gcd = gcd == 0 ? i : gcd(gcd, i);10return gcd >= 2;11}1213private int gcd(int a, int b) {14return b == 0 ? a : gcd(b, a % b);15}16}