Given a string S containing only Uppercase letters, the task is to find the minimum number of replacement of characters needed to get a string with all vowels and if we cannot make the required string then print Impossible.
Input: str = "ABCDEFGHI" Output: AOUDEFGHI There are already 3 Vowels present in the string A, E, I we just change B and C to O and U respectively. Input: str = "ABC" Output: IMPOSSIBLE
Approach: Since there are only 5 vowels A, E, I, O, U. So, If the string length is less than 5 it is always impossible.
For a string of length greater than equal to 5, it is always possible. Just iterate over each character and replace it with the vowel that doesn’t exists in the string. If the current character is a vowel and if it is not visited earlier then we will not change the character to the vowel. If all the vowels are already present from early then no need to change any character.
Below is the implementation of the above approach:
- Modify string by removing vowels in between two consonants
- Reverse vowels in a given string
- Remove consecutive vowels from string
- Program to remove vowels from a String
- Print reverse string after removing vowels
- Check whether the vowels in a string are in alphabetical order or not
- Python | Count and display vowels in a string
- Replace all consonants with nearest vowels in a string
- Program to count vowels in a string (Iterative and Recursive)
- Count the number of vowels occurring in all the substrings of given string
- Python program to count number of vowels using sets in given string
- Program to count vowels, consonant, digits and special characters in string.
- Encrypt string with product of number of vowels and consonants in substring of size k
- Find substrings that contain all vowels
- Longest substring of vowels
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.