Given a string S consisting only of lowercase letters, the task is to check if the frequency of all characters of the string is unique.
Input : abaccc Output : Yes ‘a’ occurs two times, ‘b’ occurs once and ‘c’ occurs three times. Input : aabbc Output : No Frequency of both 'a' and 'b' are same.
One thing to observe in this problem is that position of characters does not matter here so, simply count the frequency of characters. Go through the string and count the occurrence of all characters. Then sort the frequency array and check if consecutive elements are same and immediately print “No” else print “Yes”.
- Sum and Product of Prime Frequencies of Characters in a String
- Python | Ways to check string contain all same characters
- Python program to check if a string contains all unique characters
- Check whether second string can be formed from characters of first string
- Python | Extract only characters from given string
- Iterate over characters of a string in Python
- Python - String uncommon characters
- Python | Get positional characters from String
- Python | Split multiple characters from string
- Python | Convert a list of characters into a string
- Concatenated string with uncommon characters in Python
- Python | Split string into list of characters
- Python | Splitting string to list of characters
- Python | Return lowercase characters from given string
- Python - Characters Index occurrences in String
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.