← Affirm Interview Insights

Affirm·Software Engineer·Online Assessment (OA)·Intermediate

Intermediate
Apr 2026

Summary

Affirm software engineer OA on HackerRank. The problem was more business-logic flavored than pure algo grinding, which I wasn't expecting. Took me longer than it should have to even parse the problem statement.

Questions Asked (1)

Q1

Given a list of user redeem events (each with a timestamp, operation type of redeem or unredeem, and an offer ID), and a set of pre-defined promotion offers (each with an ID, start/end time, and max redemption count per user), output for each user the offers they are eligible to have redeemed before a given cutoff date.

Algorithms & Data StructuresData Modeling
Author's notes

The problem itself isn't algorithmically hard.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the requirements and edge cases first, then propose a solution that processes events in chronological order while maintaining per-user, per-offer redemption counts and eligibility based on offer time windows. Use a hash map keyed by user and offer to track state, and filter by cutoff date to output eligible offers.

Pro tip: Discuss how to handle out-of-order events and the importance of idempotency in redeem/unredeem operations, as real-world data may have duplicates or late-arriving events. Also, mention the trade-off between memory usage and query speed when pre-aggregating results.

1. Clarify requirements and edge cases

Ask about the definition of 'eligible to have redeemed' (e.g., does it mean the user has redeemed at least once, or is currently eligible to redeem?), how to handle multiple redeems/unredeems, and whether the cutoff date is inclusive. Confirm the output format.

2. Design data structures

Propose using a hash map to store per-user, per-offer redemption counts and a set to track active redemptions. Also, consider indexing offers by ID for quick lookup of time windows and max counts.

3. Process events chronologically

Sort events by timestamp (if not already sorted) and iterate through them up to the cutoff date. For each event, update the redemption count for the user and offer, ensuring not to exceed the max redemption count per user.

4. Determine eligibility

After processing events, for each user, check which offers they have redeemed at least once (or are eligible for) based on the final state. Apply any additional constraints such as offer time windows relative to the cutoff date.

5. Output results

Format the output as a mapping from user to a list of offer IDs they are eligible to have redeemed before the cutoff date. Discuss potential optimizations for large datasets, such as streaming processing or batch aggregation.

Key Points to Mention

  • Time window validation: ensure redemptions occur within the offer's start and end times.
  • Max redemption count per user: enforce the limit and handle attempts to exceed it.
  • Handling unredeem events: decrement counts and update eligibility accordingly.
  • Cutoff date filtering: only consider events with timestamp before (or on) the cutoff.
  • Data structures: hash maps for O(1) average lookup, sets for active redemptions.
  • Scalability: consider memory usage and potential for parallel processing.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.