← Tinder Interview Insights

Tinder·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Interviewed for a software engineering role at Tinder and got a classic streaming median problem. Clean technical question, nothing too surprising, but the two-heaps approach is one of those things you either know cold or you fumble through.

Questions Asked (1)

Q1

Design a data structure that supports adding numbers from a stream and returning the current median at any point.

Algorithms & Data Structures
Author's notes

The trick is knowing to reach for two heaps immediately.

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) to maintain the median in O(log n) insertion and O(1) retrieval. Explain how to balance the heaps after each insertion and handle even/odd total counts.

Pro tip: Discuss the trade-offs between this heap-based approach and alternatives like a balanced BST or sorted list, and mention how you would handle duplicates and large streams.

1. Clarify requirements

Ask about the expected number of elements, frequency of median queries, and whether the stream is unbounded. Confirm that the median is the middle value for odd counts and the average of two middle values for even counts.

2. Propose the two-heap approach

Describe using a max-heap to store the smaller half and a min-heap to store the larger half. Explain that this keeps the median at the top of one or both heaps.

3. Detail insertion and balancing

Explain the algorithm: add the new number to the appropriate heap, then rebalance by moving the top element if the size difference exceeds 1. Ensure the max-heap's top is <= the min-heap's top.

4. Compute the median

If the heaps are equal in size, the median is the average of their tops; otherwise, it's the top of the larger heap. This gives O(1) retrieval.

5. Analyze complexity and edge cases

State that insertion is O(log n) and median retrieval is O(1), with O(n) space. Discuss handling empty stream, single element, and duplicates.

Key Points to Mention

  • Two heaps: max-heap for lower half, min-heap for upper half
  • Balancing condition: size difference at most 1
  • Time complexity: O(log n) insertion, O(1) median retrieval
  • Space complexity: O(n)
  • Handling even and odd total counts
  • Alternative approaches: balanced BST, sorted list, or order statistic tree

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