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 - Replace duplicate Occurrence in String
- Python - Remove front K characters from each string in String List
- Python | Find keys with duplicate values in dictionary
- Python - Key with all Characters in String
- Iterate over characters of a string in Python
- Python | Extract only characters from given string
- Python - String uncommon characters
- Python | Extract characters except of K string
- Python - String with most unique characters
- Python | Get positional characters from String
- Python | Return lowercase characters from given string
- Check if both halves of the string have same set of characters in Python
- Python | Removing unwanted characters from 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.