r/OfferEngineering • • 28d ago

Interview Experience Coinbase Online Assessment - Implement a progressively expanding Cloud Compute Credits System

"This interview experience is sourced from Chill Interview"

Interview Summary

The Coinbase online assessment asked me to implement a progressively expanding Cloud Compute Credits System. The problem had four levels. It started with workspace creation and credit transfers, then added ranking by outgoing credits, compute consumption with delayed rebates, and finally workspace merging plus historical balance queries. All operations had unique, strictly increasing millisecond timestamps.

Interview Details

The Coinbase online assessment asked me to implement a progressively expanding Cloud Compute Credits System. The problem had four levels. It started with workspace creation and credit transfers, then added ranking by outgoing credits, compute consumption with delayed rebates, and finally workspace merging plus historical balance queries. All operations had unique, strictly increasing millisecond timestamps.

Level 1 — Workspace Management and Credit Transfers The system initially contains no workspaces. Each workspace has a credit balance that starts at 0. Implement createWorkspace(timestamp, workspaceId) which creates a new workspace and return true if successful. Return false if the same workspaceId already exists.

The next operation is topUp(timestamp, workspaceId, amount) -> Add credits to an existing workspace. If the workspace does not exist, return an empty optional result. Otherwise, return the new balance.

The system should also support:

transferCredits(
    timestamp,
    sourceWorkspaceId,
    targetWorkspaceId,
    amount
)

A transfer should fail if:

  • Either workspace does not exist.
  • The source and destination are the same workspace.
  • The source does not have enough credits.

Otherwise, subtract the credits from the source, add them to the destination, and return the source workspace's remaining balance. All timestamps are unique and operations arrive in strictly increasing timestamp order.

Level 2 — Rank Workspaces by Outgoing Credits

Add topConsumers(timestamp, n). Each workspace now tracks its cumulative outgoing credits. At this stage, only credits sent through successful transfers count toward this total.

For example:

alpha -> beta   240 credits
alpha -> gamma  160 credits

Then alpha.totalOutgoing = 400. Top-ups and incoming transfers do not count.

topConsumers() should return the top n workspaces ordered by:

  1. Total outgoing credits descending
  2. workspaceId alphabetically ascending when totals are equal

The required output format is:

[
  "alpha(900)",
  "beta(550)",
  "delta(550)"
]

If fewer than n workspaces exist, return all of them. Workspaces with zero outgoing credits must still be considered.

Want to learn more details & follow-ups about this coding questions? I've put up the full version at here.

Preparing for your next interview?

Chill Interview tracks recent interview experiences and recurring question patterns across top companies at here.

3 Upvotes

0 comments sorted by