Given a string S of lower case characters. The task is to check whether a the given string is Heterogram or not. A heterogram is a word, phrase, or sentence in which no letter of the alphabet occurs more than once.
Input : S = "the big dwarf only jumps" Output : Yes Each alphabet in the string S is occurred only once. Input : S = "geeksforgeeks" Output : No Since alphabet 'g', 'e', 'k', 's' occurred more than once.
We have existing solution for this problem please refer Check whether a given string is Heterogram or not link. We can solve this problem quickly in python using Set data structure. Approach is very simple,
- To check sentence is heterogram or not we only concern about alphabets not any other character, so we separate out list of all alphabets present in sentence.
- Convert list of alphabets into set because set contains unique values, if length of set is equal to number of alphabets that means each alphabet occured once then sentence is heterogram, otherwise not.
- Python | Check whether a string is valid json or not
- Python | Check whether string contains only numbers or not
- Python - Check whether a string starts and ends with the same character or not (using Regular Expression)
- Python - Check whether the given List forms Contiguous Distinct Sub-Array or Not
- Check whether a given column is present in a Pandas DataFrame or not
- Python | Check if a given string is binary string or not
- Python program to check whether a number is Prime or not
- Python regex | Check whether the input is Floating point number or not
- Python | Check whether two lists follow same pattern or not
- Python PRAW – Check whether a redditor has Reddit premium or not
- How to check whether the day is a weekday or not using Pandas in Python?
- Test whether the elements of a given NumPy array is zero or not in Python
- Check whether the sum of absolute difference of adjacent digits is Prime or not
- Python program to check whether the string is Symmetrical or Palindrome
- Python program to check if a given string is Keyword or not
- Python | Check if given string is numeric or not
- Python | Check whether given key already exists in a dictionary
- Python Tweepy – Checking whether a tweet has been liked or not
- Python Tweepy – Checking whether a tweet has been retweeted or not
- Python PRAW – Checking whether a redditor is a moderator or not