Class Solution
-
- All Implemented Interfaces:
public final class Solution3591 - Check if Any Element Has Prime Frequency.
Easy
You are given an integer array
nums.Return
trueif the frequency of any element of the array is prime , otherwise, returnfalse.The frequency of an element
xis the number of times it occurs in the array.A prime number is a natural number greater than 1 with only two factors, 1 and itself.
Example 1:
Input: nums = 1,2,3,4,5,4
Output: true
Explanation:
4 has a frequency of two, which is a prime number.
Example 2:
Input: nums = 1,2,3,4,5
Output: false
Explanation:
All elements have a frequency of one.
Example 3:
Input: nums = 2,2,2,4,4
Output: true
Explanation:
Both 2 and 4 have a prime frequency.
Constraints:
1 <= nums.length <= 1000 <= nums[i] <= 100
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
Modifier and Type Method Description final BooleancheckPrimeFrequency(IntArray nums)-
-
Method Detail
-
checkPrimeFrequency
final Boolean checkPrimeFrequency(IntArray nums)
-
-
-
-