Given a string in such a way that every character occurs in a repeated manner. Your task is to print the string by inserting the frequency of each unique character after it and also eliminating all repeated characters.
Input : GeeeEEKKKss Output : G1e3E2K3s2 Input : ccccOddEEE Output : c4O1d2E3
One approach to solve the above problem is to start a loop till the end of the string and for every iteration, increment a count till the character at ith position matches the following character.
Below is the implementation to the above given problem.
G1 e3 E2 K3 s2 c4 O1 d2 E3
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
- Maximum length prefix such that frequency of each character is atmost number of characters with minimum frequency
- Map every character of one string to another such that all occurrences are mapped to the same character
- Find the number of occurrences of a character upto preceding position
- Frequency of each character in a String using unordered_map in C++
- Longest sub-string having frequency of each character less than equal to k
- Print the frequency of each character in Alphabetical order
- Check if the frequency of any character is more than half the length of the string
- Largest index for each distinct character in given string with frequency K
- Character whose frequency is equal to the sum of frequencies of other characters of the given string
- Index of character depending on frequency count in string
- Check if frequency of each character is equal to its position in English Alphabet
- Minimum addition/removal of characters to be done to make frequency of each character prime
- Length of the largest substring which have character with frequency greater than or equal to half of the substring
- Frequency of smallest character in first sentence less than that of second sentence
- Maximum difference between frequency of two elements such that element having greater frequency is also greater
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.