Coinbase software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.
Question For this problem, you will be designing a series of different iterator classes. This problem is split into multiple related parts that...
Input: Array of integersQuestion Your task is to implement a simple in-memory cloud storage system that maps objects (files) to their metadata (name, size, etc.). You...
Input: Graph (nodes and edges)Question Design a banking system that supports account management, transactions, and various financial operations.
Input: Graph (nodes and edges)KnowledgeBaseSystem that stores articles with CRUD operations. The system operates entirely...Input: Graph (nodes and edges)account_id, the secondary key is an asset, and the value is an opaque decimal string such as "50.00".Each mutation has an integer timestamp. Mutation timestamps are strictly increasing across the entire store, including deletions of nonexistent keys. Reads may request any timestamp, including timestamps earlier than the most recent mutation. A read without a timestamp returns the latest state.A write makes its value visible starting at its timestamp, replacing the previous value for that account/asset pair. Deleting an asset makes that pair absent starting at the deletion timestamp. Deleting an account makes every asset belonging to that account absent, without destroying earlier history. Later writes may recreate an asset or account, but must not resurrect other previously deleted values.Historical reads return the state after all mutations whose timestamps are less than or equal to the requested timestamp. Reading a missing pair returns null; reading all assets of a missing account returns {}. Deleting a missing key is permitted and still consumes its timestamp. Reads do not change the store.An account deletion must not scan its assets. Each mutation should take amortized O(1) time, and a pair lookup should use binary search over the relevant histories rather than scan events. An account-wide read may inspect every distinct asset ever written under that account. Return maps have no required key order.Function or class signatureHistoricalBalanceStore() — construct an empty store.set(account_id: str, asset: str, value: str, timestamp: int) -> Nonedelete_asset(account_id: str, asset: str, timestamp: int) -> Nonedelete_account(account_id: str, timestamp: int) -> Noneget(account_id: str, asset: str, timestamp: int | None = None) -> str | Noneget_all(account_id: str, timestamp: int | None = None) -> dict[str, str]{
"operations": [
["set", "acct-A", "BTC", "0.50", 10],
["set", "acct-A", "ETH", "2.00", 20],
["set", "acct-A", "BTC", "0.75", 30],
["get", "acct-A", "BTC", 25],
["delete_asset", "acct-A", "BTC", 40],
["get", "acct-A", "BTC"],
["get_all", "acct-A", 35],
["get_all", "acct-A"]
]
}null:[null, null, null, "0.50", null, null, {"BTC": "0.75", "ETH": "2.00"}, {"ETH": "2.00"}]{
"operations": [
["set", "acct-B", "BTC", "1.00", 5],
["set", "acct-B", "ETH", "4.00", 8],
["delete_account", "acct-B", 12],
["get_all", "acct-B", 12],
["set", "acct-B", "BTC", "0.25", 15],
["get_all", "acct-B"],
["get_all", "acct-B", 11],
["delete_account", "acct-B", 18],
["get", "acct-B", "BTC", 15],
["get_all", "acct-B"]
]
}[null, null, null, {}, null, {"BTC": "0.25"}, {"BTC": "1.00", "ETH": "4.00"}, null, "0.25", {}]"0.25".Constraints:[1, 10^18]; mutation timestamps are globally strictly increasing. Query timestamps need not be increasing.get_all calls is at most 200,000, but accounts may have many historical assets that are currently absent.set creates a new version without destroying older versions. An empty string is a valid value and is different from a missing value.ValueError, without changing any state.None for a missing setting. Reads before the first mutation or after the last mutation are valid.delete_subkey makes one setting absent from its timestamp onward. delete_key makes every setting under that product absent from its timestamp onward. Both preserve historical reads. A subsequent set recreates only the specified setting: it must not resurrect other deleted settings.get_all returns a new dictionary containing only settings visible at the requested time. Return an empty dictionary for a product with no visible settings. Dictionary order is not significant, and modifying a returned dictionary must not change the store.delete_key. Historical point reads must use binary search rather than scanning every version. Deletes of missing products or settings are valid mutations.Class APIAssetConfigStore() — construct an empty store.set(product: str, setting: str, value: str, timestamp: int) -> None — append a setting version.get(product: str, setting: str, timestamp: Optional[int] = None) -> Optional[str] — retrieve the visible value at the requested time.get_all(product: str, timestamp: Optional[int] = None) -> dict[str, str] — retrieve all visible settings for a product.delete_subkey(product: str, setting: str, timestamp: int) -> None — append a setting-deletion marker.delete_key(product: str, timestamp: int) -> None — append a product-deletion marker without visiting its settings.set("BTC-USD", "min_order", "0.0001", 10)
set("BTC-USD", "status", "online", 20)
set("BTC-USD", "min_order", "0.0002", 30)
get("BTC-USD", "min_order", 25)
delete_key("BTC-USD", 40)
get_all("BTC-USD", 35)
get_all("BTC-USD", 40)
set("BTC-USD", "status", "post_only", 50)
get_all("BTC-USD")null represents None):[null, null, null, "0.0001", null, {"min_order": "0.0002", "status": "online"}, {}, null, {"status": "post_only"}]status, but the older min_order remains deleted.Example 2:set("ETH-USD", "notice", "", 5)
get("ETH-USD", "notice", 4)
get("ETH-USD", "notice", 5)
delete_subkey("ETH-USD", "notice", 8)
get("ETH-USD", "notice", 8)
set("ETH-USD", "notice", "maintenance", 12)
get_all("ETH-USD", 7)
get_all("ETH-USD", 10)
get_all("ETH-USD", 100)[null, null, "", null, null, null, {"notice": ""}, {}, {"notice": "maintenance"}]maintenance at 12. A future read sees all mutations recorded so far.Constraints[0, 10^12]. Out-of-range read timestamps also raise ValueError. String arguments and argument types satisfy the stated bounds.get_all may inspect every setting ever recorded for the product.Sign up for free to access walkthroughs, AI-generated questions, and more.
Get Started Free