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.
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
- 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 duplicates from a given string in Python
- Remove all consecutive duplicates from the string
- Remove three consecutive duplicates from string
- Remove duplicates from a string in O(1) extra space
- Character replacement after removing duplicates from a string
- 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++?