Skip to content

Commit a991a45

Browse files
Merge pull request #1822 from CodingTestStudy2/남효정
[남효정] Day14
2 parents 213ae5a + 4a83f95 commit a991a45

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from collections import Counter
2+
import math
3+
4+
class Solution:
5+
def hasGroupsSizeX(self, deck: List[int]) -> bool:
6+
# 모든 숫자의 등장 횟수 찾기
7+
counts = Counter(deck).values()
8+
g = 0
9+
10+
# 등장 횟수 간의 최대 공약수 찾기
11+
for count in counts:
12+
g = math.gcd(g, count)
13+
14+
# 최대 공약수가 1이면 배열 구할 수 없음
15+
if g > 1:
16+
return True
17+
return False
18+

0 commit comments

Comments
 (0)