Extract Vowels

Easy
0/40
0 upvote
Asked in company
HCL Technologies

Problem statement

You are given a string S which may contain a mix of uppercase letters, lowercase letters, and other characters. Your task is to find all the vowel characters within this string and return them as a new string.


Rules:

  • The vowels are 'a', 'e', 'i', 'o', 'u'.
  • The search must be case-insensitive, meaning both 'a' and 'A' are considered vowels and should be included in the result.
  • The vowels in the output string must appear in the same order as they did in the original string.
  • If no vowels are present in the input string, your function should return an empty string.

Detailed explanation ( Input/output format, Notes, Images )
Input Format:
The first and only line of input contains a single string S.


Output Format:
Your function should return a single string containing only the extracted vowels. The runner code will handle printing this returned value.
Sample Input 1:
Hello World


Sample Output 1:
eoo


Explanation for Sample 1:
The program scans the string. The vowels, in order of appearance, are 'e', 'o', and 'o'.


Sample Input 2:
Programming Is Fun


Sample Output 2:
oaiIu


Explanation for Sample 2:
The vowels are extracted in their original order and case: 'o', 'a', 'i', 'I', 'u'.


Expected Time Complexity:
The expected time complexity is O(N).


Constraints:
0 <= length of S <= 10^5
The string S can contain any standard ASCII characters.
Time Limit: 1 sec
Approaches (1)
Brute Force
Time Complexity
Space Complexity
Code Solution
(100% EXP penalty)
Extract Vowels
Full screen
Console