14. Write a C++ Program to Remove the Vowels from a String
14. Write a C++ Program to Remove the Vowels from a String
Given a string, remove the vowels from the string and print the
string without vowels.
Examples:
Input : welcome to geeksforgeeks
Output : wlcm t gksfrgks
C++14
Java
Python3
C#
Javascript
#include <bits/stdc++.h>
using namespace std;
if (find(vowels.begin(), vowels.end(),
str[i]) != vowels.end())
i -= 1;
return str;
// Driver Code
int main()
return 0;
// sanjeev2552
Output
GksfrGks - Cmptr Scnc Prtl fr Gks
Time Complexity: O(n), where n is the length of the string
Auxiliary Space: O(1)
We can improve the above solution by using Regular
Expressions.
Implementation:
C++
Java
Python3
C#
Javascript
regex r("[aeiouAEIOU]");
// Driver Code
int main()
return 0;
Output
GksfrGks - Cmptr Scnc Prtl fr Gks
Time Complexity: O(n), where n is the length of the string
Auxiliary Space: O(1)