Given a string str of lowercase English alphabets, the task is to check whether the string is a vowel prime or not. A string is said to be vowel prime if all the vowels in the string appear at only prime indices.
Input: str = “geeksforgeeks”
str = ‘e’ is a vowel but 1 is not prime.
Input: str = “bcae”
All the vowels are at prime indices i.e. 2 and 3.
Approach: Use Sieve of Eratosthenes to find all the prime numbers less than N so that every index of the string can be checked for primality. Now, if there is some non-prime index such that the character at that position is a vowel then the string is not vowel prime else it is.
Below is the implementation of the above approach:
- Python program to check if given string is vowel Palindrome
- Check whether the frequencies of all the characters in a string are prime or not
- Check whether count of distinct characters in a string is Prime or not
- Alternate vowel and consonant string
- Lexicographically first alternate vowel and consonant string
- Print all Subsequences of String which Start with Vowel and End with Consonant.
- Count the nodes of the tree whose weighted string contains a vowel
- Check if a number is Prime, Semi-Prime or Composite for very large numbers
- Quick ways to check for Prime and find next Prime in Java
- Check if a prime number can be expressed as sum of two Prime Numbers
- Check whether the sum of prime elements of the array is prime or not
- Check n^2 - m^2 is prime or not
- Check if N is Strong Prime
- Check if N is a Factorial Prime
- Check if a number is Full Prime
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.