← Ripple Interview Insights

Ripple·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Ripple software engineer interview with a coding problem around order book logic and greedy algorithms. Pretty domain-specific given what Ripple does, which made it feel less like a generic leetcode screen and more like something you'd actually work on there.

Questions Asked (1)

Q1

Given a list of sell orders for XRP (each with a price per XRP and a quantity), and a USD budget, write a function that calculates exactly how much XRP a customer can purchase. Partial fills on the last order are allowed.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

The greedy part clicked pretty fast: sort by price ascending, buy cheap orders first.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify that orders are processed in the given order (or sorted by price if not), then iterate through each order, consuming as much quantity as the remaining budget allows. For each order, compute the maximum affordable quantity, subtract the cost from the budget, and accumulate the total XRP purchased. Stop when the budget is exhausted or all orders are processed.

Pro tip: Mention that in real trading systems, orders are typically sorted by price (best price first) to optimize the fill, but if the list is already in execution order, you must respect that. Also, discuss how to handle floating-point precision issues by using integer arithmetic (e.g., cents) or a tolerance.

1. Clarify assumptions and input format

Confirm whether the list is sorted by price or execution order, and whether partial fills are allowed only on the last order or on any order. Also, clarify if the budget must be fully used or if leftover is acceptable.

2. Choose the right data structures and algorithm

Decide if sorting is needed (e.g., by price ascending for best deal). Use a simple loop with O(n) time and O(1) space, or O(n log n) if sorting.

3. Implement the greedy consumption

For each order, calculate the maximum quantity you can buy: min(order.quantity, remaining_budget / order.price). Update remaining budget and total XRP. If budget is insufficient for any quantity, break.

4. Handle edge cases and precision

Consider zero budget, zero quantity orders, prices that don't divide evenly, and floating-point rounding. Use integer cents or a small epsilon for comparisons.

5. Test and validate with examples

Walk through a small example, including a partial fill on the last order, and verify the total XRP and remaining budget. Discuss time and space complexity.

Key Points to Mention

  • Greedy algorithm: consume orders sequentially, taking as much as possible from each until budget runs out.
  • Time complexity: O(n) if no sorting, O(n log n) if sorting by price; space complexity O(1) extra.
  • Partial fills: only the last order (or the order that exhausts the budget) may be partially filled.
  • Floating-point precision: use integer arithmetic (e.g., cents) or a tolerance to avoid rounding errors.
  • Edge cases: empty order list, zero budget, orders with zero quantity, and prices that cause fractional XRP.
  • Trade-offs: sorting by price may yield more XRP but changes execution order; if order matters, don't sort.

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