Reverse Vowels of a String
EasyTwo Pointerstwo pointers
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
Given a string s, reverse the order of only its vowels and return the resulting string. Every other character stays in its original position.
The vowels are a, e, i, o, u in both lowercase and uppercase; a vowel keeps its own case when it moves.
Examples
Input: s = "IceCreAm"
Output: "AceCreIm"
The vowels are I, e, e, A; reversed they become A, e, e, I, placed back into the vowel slots.
Input: s = "leetcode"
Output: "leotcede"
The vowels e, e, o, e are reversed to e, o, e, e.
Constraints
- 1 <= s.length <= 3 * 10^5
- s consists of printable ASCII characters
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.