DoorDash logo

DoorDash

San Francisco, CAFood Delivery

Interview Questions

Size of Friend Groups

Asked at DoorDash
technical
algorithms
union-find

Determine friend group sizes as friendships form among students.

Problem: Given n students (IDs 1 to n) and friendship queries, calculate group sizes.

Function Signature:

function sizeOfFriendGroups(n: number, queryType: string[], student: number[], student2: number[]): number

Example: Input:

  • n = 4
  • queryType = ["Friend", "Friend", "Total"]
  • student1 = [1, 2, 1]
  • student2 = [2, 3, 4]

Output: 4 Explanation: Groups {1,2,3} and {4}, sizes 3 + 1 = 4

Solution Strategy: Use Union-Find data structure for efficient group management.

Airplane Tickets Cost Estimation

Asked at DoorDash
technical
algorithms
design patterns

Calculate airplane ticket costs based on airline, distance, and seating class.

Pricing Rules:

  1. Seating Classes:
  • Economy: No charge
  • Premium: $25
  • Business: $50 + $0.25/mile
  1. Airlines:
  • Delta: $0.50/mile + OperatingCost
  • United: $0.75/mile + OperatingCost + $0.10/mile (Premium)
  • Southwest: $1.00/mile
  • LuigiAir: max($100, 2 * OperatingCost)

Example: Input:

United 150.0 Premium
Delta 60.0 Business
Southwest 1000.0 Economy
LuigiAir 50.0 Business

Output: [152.50, 95.00, 1000.00, 125.00]

Implementation: Use strategy pattern for flexible airline pricing functions.

Share Your Experience at DoorDash