Reverse Vowels of a String
String Simulation
Problem
Write a function that takes a string as input and reverse only the vowels of a string.
For example:
Thought Process
You can use 2 pointer approach for this problem
We have to convert the string to a list in order to reassign elements
Solution
Time Complexity
Time: O(n) since we are using the two pointer approach and going linearly. Also, when we look up to see if the element is a vowel, it will take O(10) which is just O(1)
Space: O(1)
Last updated
Was this helpful?