Given a string S, the task is to check and accept the given string if it contains all vowels i.e. ‘a’, ‘e’, ‘i’.’o’, ‘u’ or ‘A’, ‘E’, ‘I’, ‘O’, ‘U’.
Input: S = “GeeksforGeeks”
Output: Not Accepted
Since S does not contain vowels a, i and u
Input: S = “ABeeIghiObhkUul”
Since S contains all vowels a, e, i, o and u
- Hashing can be used to solve this problem easily. For this, a hash data structure needs to be created of size 5 such that the index 0, 1, 2, 3 and 4 represent the vowels a, e, i, o and u.
- Create a Boolean Array, as the hash data structure, to check that all vowels are present or not in the string.
- Iterate over the string character by character and if the character is vowel then mark that vowel present in the Boolean Array
- After the Iteration of the string, check that is there any vowel which is not present in the boolean array.
Below is the implementation of the above 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.
- Program to accept Strings starting with a Vowel
- Program to build a DFA to accept strings that start and end with same character
- Build a DFA to accept Binary strings that starts or ends with "01"
- NFA to accept strings that has atleast one character occurring in a multiple of 3
- Sort an Array of Strings according to the number of Vowels in them
- Count strings with consonants and vowels at alternate position
- Program to accept String starting with Capital letter
- Program to duplicate Vowels in String
- Program to remove vowels from a String
- Program to count vowels in a string (Iterative and Recursive)
- Python program to count number of vowels using sets in given string
- Program to count vowels, consonant, digits and special characters in string.
- Count number of rotated strings which have more number of vowels in the first half than second half
- Program to check if two strings are same or not
- Program to add two binary strings
- C Program to concatenate two strings without using strcat
- A Program to check if strings are rotations of each other or not
- C Program to Sort an array of names or strings
- C++ program to compare two Strings using Operator Overloading
- Python program to find uncommon words from two Strings