Flag Promo Codes Redeemed Twice Within a Seven-Day Window

Last updated: November 29, 2026

Quick Overview

Given promo redemptions as (day, customer_id, promo_code) sorted by day, return the indices of redemptions where the same customer used the same code fewer than seven days after their previous accepted use.

DoorDash
Coding & Algorithms
Software Engineer
DoorDash
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Easy

0

0

0 solved


Given promo redemptions as (day, customer_id, promo_code) sorted by day, return the indices of redemptions where the same customer used the same code fewer than seven days after their previous accepted use.

DoorDash runs constant promotions (DashPass trials, first-order discounts, restaurant-funded codes), so abuse checks are a natural easy coding prompt. The interviewer wants a clean hash map solution and, more importantly, a precise discussion of whether the window resets on rejected uses.

What the Interviewer Expects
  • Key state on the (customer, code) pair, not just the customer
  • Decide and state whether rejected redemptions move the window
  • Get the boundary right: exactly seven days apart is allowed
  • Single pass in O(n)
  • Mention memory growth and expiry of old keys
Key Topics to Cover
hash map
rolling windows
fraud rules
boundary conditions
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you also catch the same card or device used across different customer accounts?
  • What if the input is a live stream rather than a sorted list?
  • How would you allow N uses per rolling window instead of one?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements
  • Input sorted by day. Each element: (day, customer_id, promo_code).
  • A redemption is flagged if the same customer used the same code within window_days (default 7) of their last accepted r...
High-Level Design

Store last_ok[(customer, code)] = day for the most recent accepted use. For each redemption, look up the pair; if a previous accepted use exists and the gap is under the window, flag it. Otherwise a...


Submit Your Answer
Markdown supported