Given a string. The task is to find the count of characters whose number of occurrences is prime.
Input : str = "geeksforgeeks" Output : 3 Count of occurrences of characters are: g -> 2 e -> 4 k -> 2 s -> 2 f -> 1 o -> 1 r -> 1 So, g, k and s occurs prime number of times i.e. 2 Input : str = "aabbcc" Output : 3
Below is the implementation of the above approach:
- Elements of first array that have more frequencies
- Counting frequencies of array elements
- Find array elements with frequencies in range [l , r]
- Range Queries for Frequencies of array elements
- Sum of elements in an array with frequencies greater than or equal to that element
- Count frequencies of all elements in array in Python using collections module
- Count frequencies of all elements in array in O(1) extra space and O(n) time
- Check whether the sum of prime elements of the array is prime or not
- XOR of Prime Frequencies of Characters in a String
- Check whether the frequencies of all the characters in a string are prime or not
- Sum and Product of Prime Frequencies of Characters in a String
- Numbers with prime frequencies greater than or equal to k
- Sum of elements in an array having prime frequency
- Find the sum of non-prime elements in the given array
- Difference between highest and least frequencies in an array
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.