Given a string s, print reverse of string and remove the characters from the reversed string where there are vowels in the original string.
Input : geeksforgeeks Output : segrfseg Explanation : Reversed string is skeegrofskeeg, removing characters from indexes 1, 2, 6, 9 & 10 (0 based indexing), we get segrfseg . Input :duck Output :kud
A simple solution is to first reverse the string, then traverse the reversed string and remove vowels.
An efficient solution is to do both tasks in one traversal.
Create an empty string r and traverse the original string s and assign the value to the string r. Check whether, at that index, the original string contains a consonant or not. If yes then print the element at that index from string r.
Basic implementation of the above approach :
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Modify string by removing vowels in between two consonants
- Reverse vowels in a given string
- Print string after removing all (“10” or “01”) from the binary string
- Print reverse of a string using recursion
- Print words of a string in reverse order
- Check if a string can be converted to another string by replacing vowels and consonants
- Print an N x M matrix such that each row and column has all the vowels in it
- Print number of words, vowels and frequency of each character
- Removing string that is an anagram of an earlier string
- First X vowels from a string
- Modify the string such that it contains all vowels at least once
- Count the pairs of vowels in the given string
- Program to remove vowels from a String
- Permutations of string such that no two vowels are adjacent
- Remove consecutive vowels from string