Write an efficient C program to print all the duplicates and their counts in the input string
Algorithm: Let input string be “geeksforgeeks”
1: Construct character count array from the input string.
count[‘e’] = 4
count[‘g’] = 2
count[‘k’] = 2
2: Print all the indexes from the constructed array which have value greater than 1.
s, count = 2 t, count = 3
Time Complexity : O(n)
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
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.
- Print distinct sorted permutations with duplicates allowed in input
- Print a closest string that does not contain adjacent duplicates
- Remove duplicates from a given string
- Remove all consecutive duplicates from the string
- Remove all duplicates from a given string in Python
- Remove three consecutive duplicates from string
- Remove duplicates from a string in O(1) extra space
- Character replacement after removing duplicates from a string
- Check if string is palindrome after removing all consecutive duplicates
- Distinct permutations of a string containing duplicates using HashSet in Java
- Remove duplicates from string keeping the order according to last occurrences
- Print shortest path to print a string on screen
- Print the longest prefix of the given string which is also the suffix of the same string
- Print all possible combinations of the string by replacing '$' with any other digit from the string
- Print string after removing all (“10” or “01”) from the binary string
- How to input a comma separated string in C++?
- Maximum occurring character in an input string | Set-2
- Program to check if input is an integer or a string
- Return maximum occurring character in an input string
- Generate two output strings depending upon occurrence of character in input string.