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:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Elements of first array that have more frequencies
- Counting frequencies of array elements
- Find the frequencies of all duplicates elements in the array
- Range Queries for Frequencies of array elements
- Find array elements with frequencies in range [l , r]
- 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
- Find element in array with frequency equal to sum of frequencies of other elements
- Check whether the sum of prime elements of the array is prime or not
- XOR of Prime Frequencies of Characters in a String
- Sum and Product of Prime Frequencies of Characters in a String
- Check whether the frequencies of all the characters in a string are prime or not
- Numbers with prime frequencies greater than or equal to k
- Print characters having prime frequencies in order of occurrence
- XOR of elements in an array having prime frequency
- Sum of elements in an array having prime frequency
- Find the sum of non-prime elements in the given array
- Product of elements in an array having prime frequency
- Minimum changes required to make all Array elements Prime
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.