← DoorDash Interview Insights

DoorDash·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

DoorDash coding screen focused on interval merging for a salary calculation problem. Pretty clean problem once you see the sweep-line angle, but I spent too long second-guessing edge cases before the approach clicked.

Questions Asked (1)

Q1

Given a set of possibly overlapping delivery intervals for each courier, compute each courier's total salary where pay is a flat rate per minute of active time. Overlapping intervals for the same courier should be counted only once.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

Took me a minute to realize this was just interval union under a different costume.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem: intervals are per courier, pay is per minute of active time, and overlaps within a courier's intervals should be merged. Then propose an algorithm: for each courier, sort intervals by start time and merge overlapping ones, summing the merged durations. Finally, multiply the total active minutes by the flat rate to get the salary.

Pro tip: Mention that you would handle edge cases like zero-length intervals, intervals that touch at endpoints (e.g., [1,2] and [2,3] should be merged if they are contiguous), and large inputs by using efficient sorting (O(n log n)). Also, discuss whether to process couriers independently or in parallel for scalability.

1. Clarify requirements and assumptions

Confirm that intervals are half-open [start, end) or inclusive, and that overlapping or contiguous intervals should be merged. Ask about input format, constraints, and expected output.

2. Design per-courier interval merging

For each courier, collect all intervals, sort them by start time, and iterate through to merge overlapping intervals. Keep track of the merged intervals or directly accumulate total active minutes.

3. Compute total active time and salary

Sum the lengths of the merged intervals to get total active minutes. Multiply by the flat rate per minute to compute the courier's salary.

4. Analyze complexity and optimize

Discuss time complexity: O(n log n) per courier due to sorting, where n is the number of intervals for that courier. Space complexity O(n) for storing intervals. Consider if intervals can be processed in a streaming fashion or if couriers can be processed in parallel.

5. Test with edge cases

Walk through examples: no overlaps, full overlap, contiguous intervals, zero-length intervals, and large numbers of intervals. Verify that the algorithm handles them correctly.

Key Points to Mention

  • Sorting intervals by start time is key to efficient merging.
  • Merging condition: if the next interval's start <= current merged interval's end, they overlap (or are contiguous) and should be merged.
  • Use a variable to track the current merged interval's end, updating the total active time when a gap is found.
  • Time complexity: O(n log n) per courier, dominated by sorting; overall O(N log N) if N is total intervals across all couriers.
  • Space complexity: O(n) for storing intervals, but can be O(1) extra if merging in-place after sorting.
  • Consider scalability: process couriers independently, possibly in parallel, and discuss trade-offs of sorting vs. using a sweep line with events.

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