← Ramp Interview InsightsSoftware Engineer

Ramp·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Jun 2026Remote

Summary

Ramp coding round focused on a banking system design problem that kept growing in scope. The core ask was straightforward but the follow-up on ranking and efficiency is where things got interesting.

Questions Asked (1)

Q1

You're building a banking system with CREATE_ACCOUNT, DEPOSIT, and TRANSFER operations. Now add a TOP_ACTIVITY query that returns the top N accounts ranked by total outgoing transaction amount, with ties broken alphabetically. How do you design this efficiently, and what data structure backs it?

Algorithms & Data StructuresSystem DesignTechnical Trade-offs
Author's notes

The basic operations were fine, I got through those pretty quickly.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements: how frequent are TOP_ACTIVITY queries versus updates, and what N typically is. Then propose a data structure that maintains accounts ordered by outgoing amount with alphabetical tie-breaking, such as a balanced BST or a skip list, and discuss how to keep it updated on each transaction. Finally, analyze the time and space trade-offs and mention possible optimizations like caching or batch processing.

Pro tip: Emphasize that the choice depends on the read/write ratio: if TOP_ACTIVITY is called frequently, an ordered structure with O(log n) updates is ideal; if it's rare, a simpler approach like sorting on demand might suffice. Also, mention that tie-breaking alphabetically can be handled by using a composite key (amount, account_id) in the ordering.

1. Clarify requirements and constraints

Ask about the frequency of TOP_ACTIVITY queries, the expected number of accounts, typical N, and whether the ranking should be real-time or can be slightly stale. This determines the necessary efficiency.

2. Choose a data structure

Propose an ordered data structure that supports efficient insertion, deletion, and range queries, such as a balanced binary search tree (e.g., red-black tree) or a skip list, keyed by (outgoing_amount, account_id) to handle ties alphabetically.

3. Maintain the structure on updates

On each DEPOSIT or TRANSFER, update the outgoing amount for the relevant account(s) and adjust its position in the ordered structure. For TRANSFER, decrement the sender's outgoing amount? Actually, outgoing amount increases for the sender, so update accordingly.

4. Implement TOP_ACTIVITY query

To retrieve top N, traverse the ordered structure in descending order (or use an order-statistic tree to get the largest N) and return the accounts. This takes O(N) or O(log n + N) time.

5. Discuss trade-offs and optimizations

Compare with alternative approaches like maintaining a max-heap (which doesn't support efficient updates) or sorting on demand (O(n log n) per query). Mention caching, batch updates, or approximate methods if real-time isn't required.

Key Points to Mention

  • Use a balanced BST or skip list with composite key (outgoing_amount, account_id) to handle ties alphabetically.
  • Updates (deposits/transfers) require O(log n) time to adjust the account's position in the ordered structure.
  • TOP_ACTIVITY query can be answered in O(log n + N) by traversing the tree in reverse order or using order statistics.
  • Trade-off: if TOP_ACTIVITY is infrequent, a simpler approach like sorting all accounts on demand (O(n log n)) might be acceptable.
  • Consider concurrency and consistency: if the system is distributed, maintaining a global ordered structure may require synchronization or eventual consistency.
  • Mention that outgoing amount only increases for the sender in a TRANSFER, so updates are monotonic, which could allow for specialized data structures like a Fenwick tree over amount buckets if amounts are bounded.

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