← Expedia Interview Insights

Expedia·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Expedia software engineer interview with a coding problem that looks simple but has a few ways to approach it. Nothing too wild, just needed to know your array patterns.

Questions Asked (1)

Q1

Given an integer array and an integer k, count the number of contiguous subarrays that contain exactly k odd numbers.

Algorithms & Data Structures
Author's notes

I went with the prefix count plus hashmap approach, tracking how many times each odd-number count had appeared and checking the difference.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use a sliding window (two pointers) to count subarrays with at most k odd numbers, then subtract the count for at most k-1 odd numbers. This yields the number of subarrays with exactly k odd numbers in O(n) time and O(1) space. Alternatively, use prefix sums of odd counts with a hash map to count pairs with difference k.

Pro tip: Clarify that the array can contain any integers, but only parity matters; also mention edge cases like k=0 or k greater than total odd numbers. This shows attention to detail and robustness.

1. Understand the problem

Restate the problem: count contiguous subarrays with exactly k odd numbers. Clarify that only the parity of elements matters, and that k can be zero or larger than the total odd count.

2. Choose an approach

Decide between sliding window (at most k minus at most k-1) or prefix sum with hash map. Explain the trade-offs: sliding window is O(n) time and O(1) space, while prefix sum uses O(n) space but is also O(n) time.

3. Implement the chosen method

For sliding window: write a helper function to count subarrays with at most k odd numbers. For prefix sum: iterate through the array, maintain a running count of odds, and use a hash map to store frequencies of previous counts.

4. Handle edge cases

Consider k=0 (subarrays with no odd numbers), k > total odds (answer 0), empty array, and large inputs. Ensure the solution handles these correctly.

5. Analyze complexity and test

State time and space complexity. Walk through a small example to verify correctness, and mention potential pitfalls like integer overflow or off-by-one errors.

Key Points to Mention

  • Sliding window technique for counting subarrays with at most k odd numbers
  • Prefix sum with hash map to count subarrays with exactly k odd numbers
  • Time complexity O(n) and space complexity O(1) for sliding window, O(n) for prefix sum
  • Edge cases: k=0, k > total odds, empty array, all even or all odd
  • Difference between 'exactly k' and 'at most k' and how to convert
  • Parity of elements: only odd/even matters, not actual values

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