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”.