Given a string message, your task is to shift each vowel to the position of the next…
- User
Given a string message, your task is to shift each vowel to the position of the next vowel in the string. The last vowel should be shifted to the position of the first vowel of the string. See the examples for a detailed explanation. Note: The list of vowels is: "a" "E", “i”, "o", ", "u" Note: You are not expected to provide the most optimal solution, but a solution with time complexity not worse than (message. length^2) will fit within the execution time limit.
Example
For message = "codesignal", the output should be solution (message) = "cadosegnil" Explanation: The given string "codesignal" contains the following vowels: message [1] = "o" , message [3] = "e" message [5] = "¡" , message [8] = "a"
- Assistant
To solve the problem of shifting vowels in a given string to the positions of the next vowel, with the last vowel wrapping around to the first vowel's position, we can follow these steps:
-
Identify the Vowels and Their Positions:
-