Given a string , the task is to check if the frequencies of all the characters of the string are prime or not. If all the frequencies are prime then print otherwise print .
Input: str = “geeksforgeeks”
Character Frequency g 2 e 4 k 2 s 2 f 1 o 1 r 1
It is clear that only the frequencies of g, k and s are prime.
Input: str = “aabbbccccc”
Approach: Find the frequencies of all the characters present in the string and store them in a map. Then check whether all the frequencies are prime or not, if all the frequency are prime then print else .
Below is the implementation of the above approach:
- Check whether count of distinct characters in a string is Prime or not
- Sum and Product of Prime Frequencies of Characters in a String
- XOR of Prime Frequencies of Characters in a String
- Check whether the sum of prime elements of the array is prime or not
- Print characters having prime frequencies in order of occurrence
- Binary string with given frequencies of sums of consecutive pairs of characters
- Character whose frequency is equal to the sum of frequencies of other characters of the given string
- Minimize Cost to sort a String in Increasing Order of Frequencies of Characters
- Generate a Number in Decreasing order of Frequencies of characters of a given String
- Check whether second string can be formed from characters of first string
- Check whether the sum of absolute difference of adjacent digits is Prime or not
- Check whether a number is circular prime or not
- C Program to Check Whether a Number is Prime or not
- Python program to check whether a number is Prime or not
- Check whether the given number is Wagstaff prime or not
- Check whether the given numbers are Cousin prime or not
- Check whether N is a Dihedral Prime Number or not
- Check whether a number is Good prime or not
- Print characters having odd frequencies in order of occurrence
- Print characters and their frequencies in order of occurrence using a LinkedHashMap in Java
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.