← Brex Interview Insights

Brex·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Brex SWE coding round, one question the whole session. It was a card game problem that looked like a clean OOP exercise but had enough edge cases to trip you up if you weren't careful about where the discount logic lived.

Questions Asked (1)

Q1

You're working on a card trading game. Cards have a gem cost per color and are themselves associated with a color. Players own gems and a hand of cards. Cards in hand give a -1 discount to future purchase costs for their color, stacking with no floor below zero. Update the affordability check and the purchase logic to account for these discounts.

Data ModelingAlgorithms & Data StructuresTechnical Trade-offs
Author's notes

The core mechanic clicked fast for me, tally up owned cards by color, subtract from the cost, clamp at zero.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the data model: each card has a color and a gem cost per color, and each card in hand provides a -1 discount to future purchases of its color. Then, derive the effective cost for each color as max(0, base_cost - discount[color]), and update the affordability check to compare total effective cost against owned gems. Finally, update the purchase logic to deduct the effective cost and add the purchased card to the hand, ensuring discounts are recalculated for subsequent purchases.

Pro tip: Mention that discounts should be computed dynamically from the current hand, and consider edge cases like multiple cards of the same color and the no-floor-below-zero rule to show thoroughness.

1. Clarify the data model

Define the structures for cards, gems, and hand. Each card has a color and a cost map (color -> gem count). The hand is a collection of cards, and owned gems is a map (color -> count).

2. Compute discounts

For each color, count the number of cards in hand of that color. The discount for that color is that count (each card gives -1).

3. Calculate effective cost

For a given card, its effective cost per color is max(0, base_cost[color] - discount[color]). The total effective cost is the sum over all colors.

4. Update affordability check

A card is affordable if for every color, owned_gems[color] >= effective_cost[color]. (Alternatively, check total effective cost <= total owned gems, but per-color check is more precise.)

5. Update purchase logic

If affordable, deduct the effective cost from owned gems per color, and add the purchased card to the hand. Recompute discounts for future purchases.

Key Points to Mention

  • Discounts are per color and stack additively (each card of that color gives -1).
  • Effective cost is max(0, base_cost - discount) per color, ensuring no negative cost.
  • Affordability must be checked per color, not just total cost, because gems are color-specific.
  • Purchase logic must deduct the effective cost, not the base cost.
  • After purchase, the new card adds to the hand, increasing discounts for its color.
  • Consider performance: precompute discounts or update incrementally when hand changes.

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