Redeemable Promotion Offers
Updated
Problem statement
You are given a list of promotion offers and a log of user redemption events.
- Each offer string has the format
offerId,startDate,endDate,maxRedeemsPerUser. - Each event string has the format
userId,date,action,offerId. Hereactionis eitherredeemorunredeem.
For every user that appears in the event log, find the offers they can still redeem on cutoffDate. An offer is redeemable for a user when both of these are true:
- The cutoff date is within the offer's date range.
- The user's net redeemed count for that offer is less than
maxRedeemsPerUser. The net count is the user'sredeemevents for that offer minus theirunredeemevents for it.
Return one line per user, written as userId:offerA,offerB. Put the users in ascending order of user id (smallest first), and list each user's offer ids in ascending order too. If no user can redeem any offer, return ["None"].
Function
findRedeemableOffers(offers: String[], events: String[], cutoffDate: String) → String[]Examples
Example 1
offers = ["O1,2015-01-01,2015-12-31,2","O2,2015-06-01,2016-01-31,1"]events = ["u1,2015-07-01,redeem,O1","u1,2015-07-02,redeem,O1","u1,2015-08-01,redeem,O2","u1,2015-09-01,unredeem,O1","u2,2015-08-01,redeem,O1"]cutoffDate = "2015-12-31"return = ["u1:O1","u2:O1,O2"]The cutoff date is inside both offers' date ranges. User u1 redeemed O1 twice and unredeemed it once, so the net count is still below the per-user limit for O1. User u1 also redeemed O2 once, which uses up the only redemption O2 allows per user. User u2 redeemed O1 once and never used O2, so both offers are still redeemable. The answer is u1:O1 and u2:O1,O2.
Example 2
offers = ["A,2015-01-01,2015-01-31,1"]events = ["u1,2015-01-02,redeem,A"]cutoffDate = "2015-12-31"return = ["None"]The only offer, A, ends in January, well before the cutoff date at the end of the year. So no user can redeem anything, and the answer is ["None"].
Constraints
- Dates are ISO strings in the form
YYYY-MM-DD. Because of this format, comparing two dates as plain strings, character by character, gives the right order.
More Affirm interview questions
- Propagating Fraud DetectorPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Cross-Day User Trust ScoresPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Count Distinct Underwriting PII ValuesPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- High-Card Pot GamePHONE SCREEN · Seen Sep 2026
- Assign Sequential Loan IdentifiersPHONE SCREEN · Seen Sep 2026
- Normalize Loan Merchants to Root BusinessesPHONE SCREEN · Seen Sep 2026
- Group Loans by Top-Level Parent CompanyPHONE SCREEN · Seen Aug 2026
- Group Transactions by HourONSITE INTERVIEW · Seen Nov 2026
Similar questions at other companies
- Business Account KYC Verification — Parts 1–5Stripe · PHONE SCREENStripe interview questions
- LRU Cache for Query ResultsAmazon · PHONE SCREEN · ONSITE INTERVIEW
- In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
- LRU CacheServiceNow · PHONE SCREEN · ONSITE INTERVIEWServiceNow interview questions
- Mutable Points in a Hash Set and a ListMillennium · PHONE SCREENMillennium interview questions
- Route Pattern MatcherGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
- Order and Batch Open-Close LifecycleHudson River Trading · PHONE SCREENHudson River Trading interview questions
- Pins Violation Log QueriesPinterest · PHONE SCREENPinterest interview questions
- Rectangle Point Coverage CountsOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
- File Storage ServiceCresta · PHONE SCREENCresta interview questions