Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Check if Any Element Has Prime Frequency

XPChallenge Points: 10
levelLevel: Easy

You are given an array of integers.
Your task is to determine whether any value appears a prime number of times within the array.

The "frequency" of a number refers to how many times it appears in the array.
A number is considered prime if it is greater than 1 and has exactly two divisors: 1 and itself.

Return true if at least one element occurs a prime number of times; otherwise, return false.

Example 1:

Input: nums = [5,5,6,6,6,7]

Output: true

Explanation:

Number 6 appears 3 times → 3 is prime.

Example 2:

Input: nums = [10,20,30,40]

Output: false

Explanation:

Each number appears exactly once. Frequency = 1 → not prime.

Example 3:

Input: nums = [3,3,3,3]

Output: false

Explanation:

3 appears 4 times → 4 is not prime.

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result