DoorDash Coding Interview: Finished Deliveries Before Each Start

Based on questions reported for DoorDash interviews

The interviewer opens

Hi, and thanks for joining. Welcome to your interview for the software engineer role at DoorDash. We'll work through one coding problem together, and I'd like you to think out loud as you code. If you need to step out or take a break, the Pause button at the top right of your screen will pause the interview.

The problem is about Dasher delivery time slots, and it's up in the Problem tab on the right. Please read it through, take your time, and ask me any questions before you start.

The problem

A Dasher's possible deliveries for the day are time slots, and for each slot we want to know how many slots are already finished when it begins.

  • slots: a list of {start, end} records with start < end, in any order.

Return a list of integers where entry i is the number of slots whose end is less than or equal to slots[i].start. A slot ending exactly when another starts counts as finished. Entries follow the input order.

Example: slots = [{1,3},{2,5},{4,6},{6,7}] → [0, 0, 1, 3]

Constraints: 0 ≤ n ≤ 10^5.