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
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.
- Maximum length prefix such that frequency of each character is atmost number of characters with minimum frequency
- Check if frequency of each character is equal to its position in English Alphabet
- Find just strictly greater element from first array for each element in second array
- Map every character of one string to another such that all occurrences are mapped to the same character
- Generate a number such that the frequency of each digit is digit times the frequency in given number
- Longest sub-string having frequency of each character less than equal to k
- Print the frequency of each character in Alphabetical order
- Frequency of each character in a String using unordered_map in C++
- Largest index for each distinct character in given string with frequency K
- Minimum addition/removal of characters to be done to make frequency of each character prime
- Find the number of occurrences of a character upto preceding position
- Maximum difference between frequency of two elements such that element having greater frequency is also greater
- Count of Binary Strings of length N such that frequency of 1's exceeds frequency of 0's
- Array sum after replacing all occurrences of X by Y for Q queries
- Replace every elements in the array by its frequency in the array
- Count the elements having frequency equals to its value
- Maximum element in an array which is equal to its frequency
- Find sum of product of every number and its frequency in given range
- Count the elements having frequency equals to its value | Set 2
- Character whose frequency is equal to the sum of frequencies of other characters of the given 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.