2025-08-24 15:22:04 +0000 UTC
Check if Any Element Has Prime Frequency
Categories:
Links
Code
class Solution:
def checkPrimeFrequency(self, nums: List[int]) -> bool:
def is_prime(v: int) -> bool:
for i in range(2, int(math.sqrt(v)) + 1):
if v % i == 0:
return False
return True
freqs = [0] * 101
for num in nums:
freqs[num] += 1
for freq in freqs:
if freq > 1 and is_prime(freq):
return True
return False