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
- Python - String uncommon characters
- Python | Extract characters except of K string
- Python - String with most unique characters
- Iterate over characters of a string in Python
- Python | Extract only characters from given string
- Python | Get positional characters from String
- Python | Check if frequencies of all characters of a string are different
- Check if both halves of the string have same set of characters in Python
- Python | Return lowercase characters from given string