[
counter
math
]
BinarySearch 0614 Group Integers
Problem statement
https://binarysearch.com/problems/Group-Integers/
Solution
Just check that gcd of all frequencies is not equal to 1
.
Complexity
It is O(n)
for time and space.
Code
class Solution:
def solve(self, nums):
freqs = list(Counter(nums).values())
return reduce(gcd, freqs, 0) != 1