Redeem Rakuten Points From Earliest Expiring Batches First
Last updated: November 29, 2026
Quick Overview
Implement a points wallet where each earn event creates a batch with an expiry day. Support earn, balance on a given day, and redeem, which must consume unexpired batches in order of soonest expiry and fail atomically if the balance is too low.
Rakuten
November 29, 20260
0
0 solved
Implement a points wallet where each earn event creates a batch with an expiry day. Support earn, balance on a given day, and redeem, which must consume unexpired batches in order of soonest expiry and fail atomically if the balance is too low.
Rakuten Points is the glue of the ecosystem: points earned on Ichiba, Rakuten Card or Travel arrive in batches, and limited-time campaign points expire much faster than regular ones. Interviewers use this to see whether you pick a heap naturally, handle expiry lazily, and keep redemption all-or-nothing.
What the Interviewer Expects
- Choose a min-heap keyed by expiry day
- Purge expired batches lazily on each read
- Check total balance before mutating so a failed redeem changes nothing
- Handle partially consumed batches without re-pushing
- State time complexity per operation
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you make balance O(1) instead of summing the heap?
- Campaign points must be spent before regular points even if they expire later. What changes?
- How would you persist this so two concurrent redemptions cannot double spend?
- How do you emit an audit log showing which batches funded each redemption?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Operations: earn(amount, expiry_day), balance(today) and redeem(amount, today). A batch is usable while expiry_day >= today. Redeem must take from the batch that expires soonest first, so the ...
High-Level Design
Keep a min-heap of [expiry_day, seq, remaining]. The smallest expiry is always at the root, which is exactly the batch redemption should draw from. Expired batches only ever sit at the top once ever...