← Expedia Interview Insights

Expedia·Software Engineer·Onsite - Coding / Algorithms·Intermediate

Intermediate
May 2026

Summary

Expedia coding round for a software engineer role. One algorithmic question, sliding window style, the kind that looks manageable until you start thinking about edge cases and then you're suddenly spiraling.

Questions Asked (1)

Q1

Given a lowercase string, count all contiguous substrings that contain only vowels (a, e, i, o, u) and include each of the five vowels at least once. Design an O(n) solution using a sliding window or two-pointer approach with constant extra space, and explain how you handle consonants, repeated vowels, and long vowel runs.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

My first instinct was to reach for a frequency map and just slide a window, which is the right skeleton, but I kept fumbling the part where a consonant resets everything.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the problem and edge cases, then propose a sliding window approach that maintains a count of each vowel in the current window. Expand the right pointer to include characters, and when the window contains all five vowels, count all valid substrings ending at the right pointer by moving the left pointer while the window remains valid. Finally, analyze time and space complexity to show O(n) time and O(1) space.

Pro tip: Emphasize that consonants reset the window, and that counting valid substrings can be done by tracking the minimum left index for each right index, avoiding redundant checks. This demonstrates efficient handling of repeated vowels and long runs.

1. Clarify and Define

Restate the problem to ensure understanding: count contiguous substrings consisting only of vowels and containing all five vowels. Discuss edge cases like empty string, no vowels, or strings with consonants.

2. Design Sliding Window

Use two pointers (left and right) to represent a window of vowels. Maintain a frequency array for the five vowels and a count of how many vowels have frequency > 0. Expand right to include new characters; if a consonant is encountered, reset the window and move left past it.

3. Count Valid Substrings

When the window contains all five vowels, all substrings starting from left to some index before the first occurrence of a vowel that would drop the count below 5 are valid. Efficiently count these by tracking the leftmost valid start for each right.

4. Handle Consonants and Resets

When a consonant is found, reset the frequency array and set left to right+1, effectively starting a new window. This ensures only vowel-only substrings are considered.

5. Analyze Complexity

Show that each character is processed at most twice (once by right, once by left), giving O(n) time. Space is O(1) since the frequency array has fixed size 5.

Key Points to Mention

  • Sliding window with two pointers to maintain a valid window of vowels.
  • Frequency array of size 5 to track counts of each vowel.
  • Consonants act as barriers, resetting the window.
  • Counting valid substrings by finding the leftmost valid start for each right pointer.
  • Time complexity O(n) and space complexity O(1).
  • Handling repeated vowels and long vowel runs without redundant checks.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.