← Back
00:00

Subscription Email Scheduler

Stripe interview questions · Medium · Coding round · reported 31× · 6 tests

Stripe's subscription platform sends lifecycle emails to users: a welcome email when they subscribe, one or more reminder emails before the subscription expires, and an expired email once it lapses. You're given each user's subscription window and a shared offset schedule (days relative to the events), and must produce the full, chronologically-sorted list of emails to send.

Interface

interface Subscription {
  userId: string;
  startDay: number;   // day the subscription began
  durationDays: number; // subscription runs [startDay, startDay + durationDays)
}

interface EmailSchedule {
  reminderOffsets: number[]; // days *before* expiry to send a reminder, e.g. [7, 1]
}

interface ScheduledEmail {
  userId: string;
  day: number;
  type: 'welcome' | 'reminder' | 'expired';
}

buildSendSchedule(
  subscriptions: Subscription[],
  schedule: EmailSchedule,
): ScheduledEmail[]

Requirements

Idle