Your input "race car"
Your answer "reca car"
Expected answer "race car"
Given s = "leetcode", return "leotcede".
I got the same question and by looking at others' solutions, I found that I was not understanding "reverse only the vowels of a string" correctly. In "race car", the vowels are "aea", if you reverse it, it is still "aea". Hope this helps.
The question states to reverse vowels of a string, which means the input String should be considered as one long set of characters including spaces too.
"Loophole in Universe"
should not be considered as
"Loophole" "in" "Universe"
The above example has vowels
oooeiUiee hence the reverse of the vowels in the string would be
"LeephilU in enovorso"
NOTE: You need to maintain the case (Upper, Lower) of the character as well
same goes for
"Race car", vowels are
"aea" and the vowel reversed string is
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.