Remove Vowels from a given string

You are given a string STR of length N. Your task is to remove all the vowels present in that string and print the modified string.

English alphabets ‘a’, ‘e’, ‘i’, ‘o’, ‘u’ are termed as vowels. All other alphabets are called consonants.

Note: You have to only remove vowels from the string. There will be no change in the relative position of all other alphabets.

For example:
(i)  If the input string is 'CodeGeek', the output should be CdGk after removing ‘o’ and ‘e’.

(ii) If the input string is 'Odinson', the output should be 'dnsn' after removing ‘o’ and ‘i’. 
Input Format:
The first line of input contains an integer 'T' representing the number of the test case. Then the test case follows.

The first and only line of each test case contains a string STR of length N.
Output Format:
For each test case, return the modified string that contains ‘NO VOWELS’.
Note:
You do not need to print anything; it has already been taken care of. Just implement the given function.
Constraints:
1 ≤ T ≤ 100
1 ≤ N ≤ 10^4

STR may contain alphabets from 'a' to 'z' or 'A' to 'Z' and blank spaces.

Time Limit: 1 sec 
CodingNinjas
author
2y
Brute Force
  1. Iterate through the string STR from i = 0 to i = N-1 and check:
    1. If the current character is not vowel: Do nothing.
    2. Else
      1. Iterate from j = i+1 to N-2 and copy j th alphabet to j-1 th position
      2. Red...read more
CodingNinjas
author
2y
Using auxiliary string
  1. Create a new empty string, say RES
  2. Iterate through original string STR and check if the current alphabet is a vowel or not.
    1. If it is not a vowel, append it to the back of RES
    2. If it ...read more
Help your peers!
Add answer anonymously...
Flex Associate Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter