Given a string S. 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.
The idea is to make a hash array of size 26, initalised to 0. Traverse each alphabet of the given string and mark 1 in the corresponding hash array position if that alphabet is encounter first time, else return false.
Below is the implementation of this approach:
- String slicing in Python to check if a string can become empty by recursive deletion
- Check if a string can be converted to another string by replacing vowels and consonants
- Check if a string can be obtained by rotating another string 2 places
- Check if a string can be obtained by rotating another string d places
- Queries to check if string B exists as substring in string A
- Check if a string can become empty by recursively deleting a given sub-string
- Check if a string can be repeated to make another string
- Check if a string contains a palindromic sub-string of even length
- Check whether second string can be formed from characters of first string
- Check if a given string is sum-string
- Check if given string contains all the digits
- Check if a string follows a^nb^n pattern or not
- Check if a string is Isogram or not
- Check if a string is substring of another
- Check if one string can be converted to another
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.
Improved By : manishshaw1