Allocate Rewards Redemptions to Earned Miles Lots First In First Out

Last updated: November 29, 2026

Quick Overview

Venture miles are earned in lots that each expire on a date. Given earn events and redemptions per customer, allocate each redemption to the oldest unexpired lots first, output which lots funded each redemption, and report any shortfall.

Capital One
Data Manipulation (SQL/Python)
Software Engineer
Capital One
November 29, 2026
Software Engineer
Technical Screen
Data Manipulation (SQL/Python)
Hard

0

0

0 solved


Venture miles are earned in lots that each expire on a date. Given earn events and redemptions per customer, allocate each redemption to the oldest unexpired lots first, output which lots funded each redemption, and report any shortfall.

Rewards accounting at Capital One has to explain exactly which earned miles were spent, both for customer statements and for the finance liability on unredeemed rewards. The interviewer checks that you can process mixed events chronologically, maintain per-customer state, and handle expiry and partial lot consumption.

What the Interviewer Expects
  • Merges earn and redemption events into one chronological stream
  • Breaks timestamp ties so earns on the same instant are available
  • Keeps per-customer lots ordered by earn time
  • Skips lots that expired before the redemption
  • Partially consumes lots and records allocations
  • Reports shortfalls instead of silently going negative
Key Topics to Cover
event processing
heaps
FIFO allocation
pandas
rewards accounting
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
  • How would you change the policy to consume the soonest-expiring lot first?
  • How would you compute the outstanding liability of unexpired miles at month end?
  • How would you process this for millions of customers in Spark?
Sharpen Your Skills on Codemia

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

Practice SQL Problems
Sample Answer
Clarify the Data
  • earns(earn_id, customer_id, ts, points, expires_ts) and redemptions(redemption_id, customer_id, ts, points).
  • FIFO means by earn time. A lot is usable only if expires_ts > redemption ts.
  • If...
Approach

Build one event list sorted by (ts, kind, id) with earns as kind 0. Keep a min-heap of lots per customer keyed by (earn_ts, earn_id). On a redemption, look at the top lot: if expired, pop it; othe...


Submit Your Answer
Markdown supported