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:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Check whether the binary equivalent of a number ends with given string or not
- Check whether the vowels in a string are in alphabetical order or not
- Check whether count of distinct characters in a string is Prime or not
- Check whether the frequencies of all the characters in a string are prime or not
- Check whether the Average Character of the String is present or not
- C++ program to check whether a String is a Pangram or not
- Check whether given string can be generated after concatenating given strings
- Check whether two strings are equivalent or not according to given condition
- Check whether second string can be formed from characters of first string
- Check if a given string is a Reverse Bitonic String or not
- Check whether a binary string can be formed by concatenating given N numbers sequentially
- Check whether the given string is a valid identifier
- Check whether the given decoded string is divisible by 6
- Check whether the string S1 can be made equal to S2 with the given operation
- Check whether the given string is Palindrome using Stack
- Check whether Strings are k distance apart or not
- Check whether K-th bit is set or not
- Check Whether a number is Duck Number or not
- Check if given Binary string follows then given condition or not
- Check whether frequency of characters in a string makes Fibonacci Sequence
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.
Improved By : manishshaw1