![]() |
VOOZH | about |
Given three strings(without spaces). The task is to print the new string after modifying the three given string as follows:
Examples:
Input: how are you
Output\: h*ware$ouInput: geeks for geeks
Output: g**ksfor$ee$$
Approach:
The idea is to traverse the first string and keep checking if any character is a vowel or not. Replace the character in the first string which is vowel with "*". Similarly, traverse the third string and keep checking if any character is not a vowel. If a character in the third string is not a vowel(then it is a consonant), replace it with '$'.
Finally, concatenate the three strings and print the newly concatenated string.
Below is the implementation of the above approach:
h*ware$ou
Time Complexity: O(m+n), where m is the length of the first string and n is the length of the third string.
Auxiliary Space: O(1), as constant extra space is required.