Given a string, find all the duplicate characters which are similar to each others.
Let’s look at the example.
Input : hello Output : l Input : geeksforgeeeks Output : e g k s
We have discussed a solution in below post.
Print all the duplicates in the input string
We can solve this problem quickly using python Counter() method. Approach is very simple.
1) First create a dictionary using Counter method having strings as keys and their frequencies as values.
2) Declare a temp variable.
3) Print all the indexes from the keys which have value greater than 1.
e g k s
- Python Counter| Find duplicate rows in a binary matrix
- Python | Case Counter in String
- Python Dictionary to find mirror characters in a string
- Python counter and dictionary intersection example (Make a string using deletion and rearrangement)
- Dictionary and counter in Python to find winner of election
- Python Counter to find the size of largest subset of anagram words
- Using Counter() in Python to find minimum character removal to make two strings anagram
- Python | Find keys with duplicate values in dictionary
- Python - Remove front K characters from each string in String List
- Python - String uncommon characters
- Iterate over characters of a string in Python
- Python - String with most unique characters
- Python | Extract only characters from given string
- Python | Get positional characters from String
- Python | Splitting string to list of characters
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.