FastPrepReverse Vowels of a String
Problems/Reverse Vowels of a String

Reverse Vowels of a String

Google logoGoogle● EasyNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report does not give the exact set of vowels or a size limit. Our version is about 98% the same as the reported question.

Given a string s, reverse only its vowel characters and return the resulting string.

The vowels are a, e, i, o, and u, in either lowercase or uppercase. Preserve every vowel's original character and case while reversing their order. Every non-vowel character remains at its original index.

The string may be large, so avoid repeated string rebuilding that takes quadratic time.

Function

reverseVowels(s: String) → String

Examples

Example 1

s = "hello"return = "holle"

The vowels are e and o. Reversing them produces holle.

Example 2

s = "leetcode"return = "leotcede"

The vowel sequence e, e, o, e becomes e, o, e, e; consonants keep their positions.

Example 3

s = "aA"return = "Aa"

Uppercase and lowercase vowels both participate, and their original cases move with the characters.

Constraints

  • 0 <= s.length <= 10^6.
  • s contains printable ASCII characters.

More Google Onsite Interview questions

  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Distinct Subset SumsONSITE INTERVIEW · Seen Nov 2026
  • Playlist With No Same Artist in a RowONSITE INTERVIEW · Seen Nov 2026
  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Delete Nodes and Return Forest RootsONSITE INTERVIEW · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • First and Last Target Position in a Mountain ArrayONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • 0/1 Knapsack with Weight and Volume LimitsONSITE INTERVIEW · Seen Nov 2026
  • Batched Subsequence Word MatchesONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Longest Spoken PrefixElevenLabs · ONSITE INTERVIEWElevenLabs interview questions
  • Palindrome Check Ignoring SymbolsWalmart · ONSITE INTERVIEWWalmart interview questions
  • Reverse a String Keeping Dashes in PlaceNykaa · ONSITE INTERVIEWNykaa interview questions
  • Valid Palindrome After NormalizationKotak Mahindra Bank · ONSITE INTERVIEWKotak Mahindra Bank interview questions
  • Count Binary SubstringsDocuSign · ONSITE INTERVIEWDocuSign interview questions
  • Minimum Changes for Palindromic BlocksCitadel · OA · PHONE SCREEN · ONSITE INTERVIEWCitadel interview questions
  • Palindrome Match PercentageApple · ONSITE INTERVIEWApple interview questions
  • Reverse A StringNVIDIA · ONSITE INTERVIEWNVIDIA interview questions
  • Validate a Word AbbreviationSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Run-Length String CompressionOracle · ONSITE INTERVIEWOracle interview questions

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
  • Google Experienced SWE First Round and Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public String reverseVowels(String s) {
      // Write your code here.
    }
}
Checking account…