Given a string str, the task is to check whether all the substrings of length ≥ 2 have the number of vowels at least as that of the number of consonants.
Input: str = “acaba”
The substring “cab” has 2 consonants and a single vowel.
Input: str = “aabaa”
Approach: There are only two cases where the given condition is not satisfied:
- When there are two consecutive consonants as in this case a substring of size 2 can have 2 consonants and no vowels.
- When there is a vowel surrounded by two consonants, in this case a substring of length 3 is possible with 2 consonants and 1 vowels.
All the other cases will always satisfy the given conditions.
Below is the implementation of the above approach:
- Find the number of words of X vowels and Y consonants that can be formed from M vowels and N consonants
- Number of words that can be made using exactly P consonants and Q vowels from the given string
- Encrypt string with product of number of vowels and consonants in substring of size k
- Check if a string can be converted to another string by replacing vowels and consonants
- Count of substrings consisting of even number of vowels
- Count the number of vowels occurring in all the substrings of given string
- Replace all consonants with nearest vowels in a string
- Modify string by removing vowels in between two consonants
- Longest subsequence consisting of alternate vowels and consonants
- Arrange consonants and vowels nodes in a linked list
- Modify the string by swapping continuous vowels or consonants
- Count strings with consonants and vowels at alternate position
- Minimum swaps required to move all vowels occurs after consonants in a given string
- Substrings starting with vowel and ending with consonants and vice versa
- Find substrings that contain all vowels
- Count substrings that contain all vowels | SET 2
- Count of substrings consisting only of vowels
- Queries to find the count of vowels in the substrings of the given string
- Replace consonants with next immediate consonants alphabetically in a String
- Check whether the vowels in a string are in alphabetical order or not
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.