Reverse the Interior of Vowel-Bounded Words
Reported by candidates from ZipRecruiter's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The ZipRecruiter OA reported in September 2024 looks like a string puzzle, but it boils down to one filter and one reversal per word. Check if the first and last characters are vowels, then flip the middle and leave everything else alone. It's a two-pointers problem in disguise, and it's easy if you stay calm and read the constraints. If you blank mid-assessment, StealthCoder runs invisibly on your desktop as a safety net and gives you the solution in real time. Here's the script for the pattern, the traps, and what to double-check before you submit.
The problem
For this exercise, use the callable contract below. You are given an array of strings text, where each string represents a word. A word qualifies when both its first and last characters are vowels. The vowels are a, e, i, o, and u, and the check is case-insensitive. For every qualifying word, reverse only the substring between its first and last characters. Keep the two endpoint characters unchanged. Leave every other word unchanged and preserve the original array order. Return the modified array of strings. Function reverseVowelBoundedInteriors(text: String[]) → String[] Examples Example 1 text = ["abcde","acvbn","Etuilo"] return = ["adcbe","acvbn","Eliuto"] abcde begins with a and ends with e, so reversing bcd produces adcbe. acvbn does not end with a vowel and remains unchanged. Etuilo begins and ends with vowels; reversing tuil produces Eliuto. Constraints 1 <= text.length <= 105 Every element of text is a non-empty word containing uppercase or lowercase English letters. The total number of characters across all words is at most 105. Vowel checks are case-insensitive, while every character's original case is preserved.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is to treat each word independently. Lowercase the first and last characters for the vowel check, but never lowercase the word itself, because the output must preserve original case. If both ends are vowels, reverse the substring from index 1 to length-2. Use slicing, or swap with two pointers moving inward. Total characters are capped at 10^5, so a linear pass over all words is fine. Pitfalls: single-character words (first and last are the same character, and the interior is empty, so nothing changes), two-character words (empty interior), and mutating the wrong index range. Also don't reorder the array. Build a new list and append each processed word in order. Test with Etuilo, where the uppercase E must still count as a vowel. If you freeze during the live OA, StealthCoder is the hedge that hands you the working loop.
The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.
You can drill Reverse the Interior of Vowel-Bounded Words cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass ZipRecruiter's OA.
ZipRecruiter reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Reverse the Interior of Vowel-Bounded Words FAQ
What's the actual trick in the ZipRecruiter vowel-bounded words problem?+
Per word, check the first and last characters against a lowercase vowel set, then reverse only indices 1 through n-2. Keep the endpoints and original casing. It's a simple filter plus an interior reversal, so most of the work is handling edge cases correctly.
How do I handle words with one or two characters?+
Both are no-ops. A one-letter word has the same first and last character and no interior. A two-letter word has an empty interior. Slicing handles this naturally, since reversing an empty string returns an empty string, so you rarely need a special case.
Does case matter for the vowel check?+
Only for detection. Compare lowercased first and last characters against a, e, i, o, u. Never change the word's actual case. Etuilo must become Eliuto, with the capital E still at the front and every other letter keeping its original case.
What's the time complexity I should aim for?+
O(total characters), which is at most 10^5 here. Each word is scanned once for the check and once for the reversal. Anything quadratic across the whole input is unnecessary. Don't concatenate strings in a way that copies repeatedly inside a big loop.
How do I prepare for this in 48 hours?+
Write the solution once from scratch in your language of choice. Then run it on edge cases: one-letter words, uppercase vowels, words with no vowels at the ends, and a long single word. Practice slicing and two-pointer swaps until you can write either without hesitation.