← DoorDash Interview Insights

DoorDash·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

DoorDash coding screen for a software engineer role. The problem was dressed up in delivery driver language but it was just LCS underneath, which I didn't clock immediately and cost me a few minutes of confusion.

Questions Asked (1)

Q1

You have two delivery drivers, each with an ordered list of restaurant IDs they need to pick up from. Since there's only one car, it can only visit restaurants that appear in both lists, and the order must be preserved for each driver. Find the longest possible route the car can take.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

Took me an embarrassingly long time to realize this was just longest common subsequence with a story wrapped around it.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Recognize this as the Longest Common Subsequence (LCS) problem: find the longest sequence of restaurant IDs that appears in both drivers' lists in the same relative order. Explain the dynamic programming approach, including the recurrence and how to reconstruct the actual route, and discuss time/space complexity and possible optimizations.

Pro tip: After presenting the DP solution, mention that if the lists are large and the alphabet of restaurant IDs is small, you can optimize space to O(min(m,n)) and use Hirschberg's algorithm to reconstruct the LCS in linear space. This shows you understand practical trade-offs beyond the basic solution.

1. Clarify the problem

Restate the problem to confirm understanding: we need the longest sequence of restaurant IDs that appears in both lists in the same order. Ask about constraints (list sizes, possible duplicates) and expected output (length or actual route).

2. Identify the algorithmic pattern

State that this is the Longest Common Subsequence (LCS) problem, a classic dynamic programming problem. Explain why it fits: we need to preserve order and find the longest common subsequence.

3. Define the DP recurrence

Define dp[i][j] as the length of LCS of the first i elements of list A and first j elements of list B. Give the recurrence: if A[i-1] == B[j-1], dp[i][j] = dp[i-1][j-1] + 1; else dp[i][j] = max(dp[i-1][j], dp[i][j-1]). Base cases: dp[0][j] = dp[i][0] = 0.

4. Explain reconstruction and complexity

Describe how to backtrack through the DP table to reconstruct the actual route. State time complexity O(m*n) and space complexity O(m*n), and mention space optimization to O(min(m,n)) if only length is needed.

5. Discuss trade-offs and optimizations

Mention alternative approaches (e.g., if one list is much smaller, use it as the DP dimension; if duplicates are rare, use a hash map to find matching indices and reduce complexity). Discuss Hirschberg's algorithm for linear-space reconstruction.

Key Points to Mention

  • Longest Common Subsequence (LCS) is the core algorithm.
  • Dynamic programming recurrence and base cases.
  • Time and space complexity: O(m*n) time, O(m*n) space; can optimize space to O(min(m,n)).
  • Reconstruction of the actual route using backtracking.
  • Handling duplicates: LCS naturally handles duplicates by considering all possibilities.
  • Trade-offs: when to use DP vs. other approaches (e.g., if lists are huge, consider approximate or heuristic methods).

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