From 1d2dd1e6c860be1193473c0dc84cac64e5a92bea Mon Sep 17 00:00:00 2001 From: SinnoLn Date: Wed, 12 Aug 2026 13:21:37 +0900 Subject: [PATCH] 914. X of a Kind in a Deck of Cards --- .../914. X of a Kind in a Deck of Cards.java" | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 "leetcode3/\354\235\264\354\247\204\355\235\254/914. X of a Kind in a Deck of Cards.java" diff --git "a/leetcode3/\354\235\264\354\247\204\355\235\254/914. X of a Kind in a Deck of Cards.java" "b/leetcode3/\354\235\264\354\247\204\355\235\254/914. X of a Kind in a Deck of Cards.java" new file mode 100644 index 00000000..a5995f08 --- /dev/null +++ "b/leetcode3/\354\235\264\354\247\204\355\235\254/914. X of a Kind in a Deck of Cards.java" @@ -0,0 +1,35 @@ +/* +1. 아이디어: 크기가 1보다 큰 파티션으로 배열 나누기 + 이때 각 파티션은 같은 숫자로만 이루어져야 한다. + + 최대공약수 - 유클리드 호제법 사용. + 먼저 숫자의 빈도수를 세고, 첫 빈도수 기준 최대 공약수를 각각 계산한다. + +2. 시간복잡도: O(10000*logN) + +3. 자료구조/알고리즘: 최대공약수, 카운팅 + +*/ + +class Solution { + public boolean hasGroupsSizeX(int[] deck) { + int[] cnt = new int[10001]; + + for(int i=0; i 1; + + } + + private int gcd(int a, int b) { + if(b==0) return a; + return gcd(b, a%b); + } +} \ No newline at end of file