Redeem Membership Rewards Points From Earliest Expiring Lots

Last updated: November 29, 2026

Quick Overview

Design a points ledger where points arrive in lots, each with an expiry day, and redemptions must be all or nothing and consume points from the lots that expire soonest. Support earn, redeem (returning which lots were drawn from) and the available balance on a given day.

American Express
Coding & Algorithms
Software Engineer
American Express
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


Design a points ledger where points arrive in lots, each with an expiry day, and redemptions must be all or nothing and consume points from the lots that expire soonest. Support earn, redeem (returning which lots were drawn from) and the available balance on a given day.

Loyalty programs like Membership Rewards mix permanent points with promotional bonuses that expire, and a redemption should burn the soonest-to-expire points first so card members lose as little as possible. The interviewer looks for the right data structure, atomic redemption and careful handling of expiry boundaries.

What the Interviewer Expects
  • Chooses a min-heap keyed on expiry date
  • Makes redemption atomic: check the balance after expiring, then draw
  • Expires lots lazily before reads and redemptions
  • Returns an audit trail of which lots were drawn
  • States the expiry boundary rule clearly (valid through the expiry day)
Key Topics to Cover
Heaps
Ledger design
Atomicity
Lazy expiration
Audit trail
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 do you reverse a redemption when a travel booking is cancelled?
  • How would you persist this in a database so two concurrent redemptions cannot both succeed?
  • How would you change the draw order if some lots are worth more per point than others?
  • How would you notify card members of points about to expire?
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
  • earn(lot_id, points, expires_day) adds a lot; lot ids are unique.
  • redeem(points, today) either takes exactly points from the earliest-expiring valid lots or changes nothing and returns `None...
High-Level Design

Keep a min-heap of (expires_day, seq, lot_id) and a dict of remaining points per lot, plus a running balance. Before any read or redemption, pop every lot whose expiry is before today and subtract i...


Submit Your Answer
Markdown supported

Related Questions