FastPrepDasher Active Time
Problems/Dasher Active Time

Dasher Active Time

DoorDash logoDoorDash● MediumFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: The source defines active time from an ordered pickup/dropoff sequence but omits a portable timestamp representation, equal-time behavior, malformed-sequence behavior, bounds, and the callable interface. The judged event-count sweep is an approximately 90% match.

A Dasher processes an ordered sequence of delivery events during one day. The arrays timestamps and actions have equal length. Event i occurs at minute timestamps[i] from the start of the day, and actions[i] is either PICKUP or DROPOFF.

A pickup adds one active delivery. A dropoff completes one active delivery. The sequence is valid: no prefix has more dropoffs than pickups, and every pickup is matched by the final event.

The Dasher is active whenever at least one delivery is active. Overlapping deliveries do not multiply active time. Return the total number of minutes during which the Dasher is active. If there are no events, return 0.

Timestamps are nondecreasing and each timestamp is between minute 0 and minute 1440, inclusive. When several events have the same timestamp, process them in their given order; because no time passes between them, their order does not itself add active minutes.

Function

totalActiveTime(timestamps: int[], actions: String[]) → int

Examples

Example 1

timestamps = [510,550,620,735,765,865]actions = ["PICKUP","DROPOFF","PICKUP","PICKUP","DROPOFF","DROPOFF"]return = 285

The active ranges are [510,550) and [620,865). Their lengths are 40 and 245, for 285 active minutes. The overlapping deliveries from minute 735 through 765 still contribute time only once.

Example 2

timestamps = [0,5,10,20]actions = ["PICKUP","PICKUP","DROPOFF","DROPOFF"]return = 20

The active-delivery count stays positive from minute 0 until minute 20, so the total is 20.

Example 3

timestamps = [10,10,20,20]actions = ["PICKUP","DROPOFF","PICKUP","DROPOFF"]return = 0

Each delivery is picked up and dropped off at the same minute, so neither lifecycle contains a positive-length active interval.

Constraints

  • 0 <= timestamps.length <= 100000.
  • actions.length = timestamps.length.
  • 0 <= timestamps[i] <= 1440.
  • timestamps is in nondecreasing order.
  • Every action is PICKUP or DROPOFF.
  • In every prefix, the number of dropoffs is at most the number of pickups.
  • The total number of pickups equals the total number of dropoffs.

More DoorDash problems

  • Customer Bootstrap APIPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Dasher Pay with Store Waits and Peak HoursPHONE SCREEN · Seen Nov 2026
  • Random Dasher Set OperationsONSITE INTERVIEW · Seen Nov 2026
All DoorDash interview questionsSee DoorDash hiring insights
Saved
class Solution {
    public int totalActiveTime(int[] timestamps, String[] actions) {
      // Write your code here.
    }
}
Checking account…