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 :
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- 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
- Permutations of string such that no two vowels are adjacent
- Count the pairs of vowels in the given string
- Remove consecutive vowels from string
- Program to remove vowels from a String
- Longest Subsequence of a String containing only vowels
- Program to duplicate Vowels in String
- Check whether the vowels in a string are in alphabetical order or not
- Replace all consonants with nearest vowels in a string
- Replace every vowels with lexicographically next vowel in a String
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.