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:
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Elements of first array that have more frequencies
- Counting frequencies of array elements
- Find array elements with frequencies in range [l , r]
- Find the frequencies of all duplicates elements in the array
- 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
- Find element in array with frequency equal to sum of frequencies of other elements
- 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
- Print characters having prime frequencies in order of occurrence
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.