← IXL Learning Interview Insights

IXL Learning·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Had a technical phone screen for a software engineer role at IXL Learning. The coding problem was a classic data structures question, nothing too surprising, but it still required some careful thinking about the implementation.

Questions Asked (1)

Q1

Design and implement a data structure that supports adding numbers from a stream one at a time and returning the median of all numbers seen so far at any point.

Algorithms & Data Structures
Author's notes

The two-heap approach is the clean solution here and I knew it going in, one max-heap for the lower half and one min-heap for the upper half.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use two heaps: a max-heap for the lower half and a min-heap for the upper half, keeping their sizes balanced. After each insertion, the median is either the top of the max-heap (if odd count) or the average of both tops (if even count).

Pro tip: Mention that this approach gives O(log n) insertion and O(1) median retrieval, and discuss how you would handle edge cases like empty stream or duplicate values.

1. Clarify requirements

Confirm that the data structure should support addNum(int num) and findMedian() operations, and that the median is defined as the middle value for odd count or average of two middle values for even count.

2. Choose data structures

Select a max-heap to store the smaller half of numbers and a min-heap for the larger half. This allows efficient access to the middle elements.

3. Define balancing rule

Maintain the invariant that the max-heap size is either equal to or one greater than the min-heap size. After each insertion, rebalance by moving the top element from the larger heap to the other.

4. Implement addNum

Add the new number to the appropriate heap: if it's less than or equal to the max-heap top, add to max-heap; otherwise, add to min-heap. Then rebalance the heaps.

5. Implement findMedian

If total count is odd, return the top of the max-heap. If even, return the average of the tops of both heaps.

Key Points to Mention

  • Time complexity: O(log n) for addNum due to heap insertion, O(1) for findMedian.
  • Space complexity: O(n) to store all numbers.
  • Balancing condition: max-heap size is either equal to or one greater than min-heap size.
  • Handling duplicates: heaps naturally handle duplicates without special logic.
  • Alternative approaches: balanced BST or sorted list (less efficient), but two heaps is optimal.
  • Edge cases: empty stream (return 0 or throw exception), single element, and large streams.

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