JAVA_X of a Kind in a Deck of Cards_LeetCode 914


JAVA_X of a Kind in a Deck of Cards_LeetCode 914

JAVA_X of a Kind in a Deck of Cards_LeetCode 914 풀이 class Solution { public boolean hasGroupsSizeX(int[] deck) { Map<Integer, Integer> map = new HashMap<>(); int gcd = 0; for (int i : deck){ map.put(i, map.getOrDefault(i, 0) + 1); // System.out.println(map.get(i)); } for (int val : map.values()) gcd = gcd(gcd, val); return gcd > 1; } public int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); } } * 출처 https://leetcode.com/problems/valid-phone-numbers/ Valid Phone Numbers - LeetCode Can y...


#JAVA #JAVA_LeetCode914 #JAVA_XofaKindinaDeckofCards #JAVA_XofaKindinaDeckofCards_LeetCode914 #XofaKindinaDeckofCards_LeetCode914

원문링크 : JAVA_X of a Kind in a Deck of Cards_LeetCode 914