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.
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. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.
In case you wish to attend live classes with industry experts, please refer DSA Live Classes