← DoorDash Interview InsightsSoftware Engineer

DoorDash·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

DoorDash data engineering screen with a sliding window coding problem. Pretty standard algorithmic stuff but there are a couple of small gotchas that can trip you up if you're not paying attention.

Questions Asked (1)

Q1

Given an array of daily revenue values and a window size k, find the contiguous k-day period with the highest total and return its start day as a 1-based index. Return the result inside a list.

Algorithms & Data Structures
Author's notes

The core algorithm isn't the hard part.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use a sliding window technique to compute the sum of the first k days, then slide the window by subtracting the outgoing day and adding the incoming day, keeping track of the maximum sum and its start index. Return the 1-based start index of the window with the highest sum.

Pro tip: Clarify edge cases upfront, such as when k equals the array length or when multiple windows have the same maximum sum (return the earliest). Also, mention that the solution runs in O(n) time and O(1) space, which is optimal.

1. Understand the problem and edge cases

Confirm that the array contains daily revenues, k is the window size, and you need the 1-based start index of the contiguous k-day period with the highest total. Discuss edge cases: k > array length (invalid), k = array length (only one window), and ties (return the first occurrence).

2. Choose the sliding window approach

Explain that a brute-force approach would be O(n*k), but a sliding window optimizes to O(n) by reusing the sum of the previous window. This is efficient and suitable for large inputs.

3. Initialize and compute the first window sum

Calculate the sum of the first k elements and set it as the initial maximum sum. Record the start index as 1 (1-based).

4. Slide the window and update maximum

Iterate from index k to the end of the array. For each step, update the current sum by subtracting the element leaving the window and adding the new element. If the current sum exceeds the maximum sum, update the maximum and record the new start index (current index - k + 2 in 1-based).

5. Return the result

After processing all windows, return the start index of the maximum sum window as a single-element list, e.g., [start_index].

Key Points to Mention

  • Sliding window technique reduces time complexity from O(n*k) to O(n).
  • Space complexity is O(1) as only a few variables are used.
  • Handle edge cases: k > n (return empty list or error), k = n (return [1]), and ties (return earliest index).
  • Use 1-based indexing for the start day as specified.
  • Initialize max_sum to negative infinity or the sum of the first window to handle negative revenues.
  • Return the result inside a list, e.g., [3].

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