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:
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Program to accept Strings starting with a Vowel
- Program to build a DFA to accept strings that start and end with same character
- NFA to accept strings that has atleast one character occurring in a multiple of 3
- Build a DFA to accept Binary strings that starts or ends with "01"
- 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
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.