Question You are designing an NFT generation engine. You are given a set of Traits, where each trait has a name and a list of possible...
Input: List Output: Array
codingMediumVerified Question#2
2. Blockchain Mining
Category: Dynamic programming coding problem
Question You are building a block construction module for a blockchain node. The goal is to select a subset of pending transactions to include in...
Input: Graph (nodes and edges) Output: Computed result
codingMediumVerified Question#3
3. Crypto Trading System Stream
Category: String coding problem
Question Design a crypto trading system that manages a stream of orders. The system should support various operations like placing, pausing,...
Input: Array of strings Output: Computed result
codingHardVerified Question#4
4. Design Iterators
Category: Array coding problem
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 integers Output: Computed result
codingMediumVerified Question#5
5. Food Delivery System
Category: Trie-based coding problem
Question For this problem, you will be designing a food delivery system. This problem is split into three related parts, evolving from basic data...
Input: List Output: Computed result
codingHardVerified Question#6
6. Transaction System
Category: Tree coding problemFor this problem, you will be designing a system to handle financial transactions and account balances. This problem is split into three related...Input: List Output: Integer
codingHardVerified Question#7
7. OA[CodeSignal] Cloud File Storage System
Category: Graph coding problem
Question 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) Output: Array
codingHardVerified Question#8
8. OA[CodeSignal] Design Banking System
Category: Graph coding problem
Question Design a banking system that supports account management, transactions, and various financial operations.
Input: Graph (nodes and edges) Output: Computed result
codingHardVerified Question#9
9. Capital Gains Tax Calculator
Category: String coding problemYou are given a chronologically sorted list of stock transactions. Each transaction is a list of strings in the format `[<timestamp>, <type>,...Input: Array of strings Output: Computed result
codingMediumVerified Question#10
10. Service Log Aggregator
Category: Trie-based coding problemA distributed system emits log entries from multiple services and worker threads. Each log entry is a colon-separated string in the format...Input: Array Output: Computed result
codingHardVerified Question#11
11. OA [CodeSignal] Knowledge Base System
Category: Graph coding problemDesign and implement a personal knowledge base called KnowledgeBaseSystem that stores articles with CRUD operations. The system operates entirely...Input: Graph (nodes and edges) Output: Computed result
codingMediumVerified Question#12
12. OA [CodeSignal] Workspace Tracker
Category: Interval-based coding problemBuild a system to track desk workers at a shared office space. The system records when each worker enters and leaves and computes how long they have...Input: String Output: Array
codingHardVerified Question#13
13. Transaction Query Engine
Category: String coding problemDesign a system to filter and paginate a list of transaction records. Each record is a list of strings in the format `[timestamp, id, userId,...Input: Array of strings Output: Computed result
codingMediumVerified Question#14
14. Exchange Rate Finder
Category: String coding problemYou are given a set of currency exchange relationships. Each relationship specifies a direct exchange rate between two currencies. Rates are...Input: List Output: Computed result
codingHardVerified Question#15
15. Order Matching Engine
Category: String coding problemYou are managing a cryptocurrency order book. The book holds buy and sell orders placed by traders. - A buy order indicates the maximum price a...Input: String Output: Computed result
codingHardVerified Question#16
16. Account Transfer System
Category: String coding problemYou are given a list of fund transfer instructions and a set of accounts with initial balances. Each transfer moves a fixed percentage of the...Input: List Output: Computed result
codingHardVerified Question#17
17. Restaurant Delivery Network
Category: String coding problemYou are building a food discovery platform. Given a user's location, a list of restaurants with their coordinates, and a menu of items with prices,...Input: List Output: Computed result
codingMediumclosure#1
1. [OA] Closures — Create a series of functions to track user account balance on Coinbase.
As a finance platform, accurately maintaining user balances is fundamental. Understanding closures helps in creating a secure balance management system. Problem Statement: You need to define a function createAccountManager(initialBalance: number): { deposit: Function; withdraw: Function; getBalance: Function; } that returns an object with methods to deposit, withdraw, and getBalance. Using closures, ensure that the balance is encapsulated and not directly accessible.
deposit(amount: number): void — Adds an amount to the balance.
withdraw(amount: number): void — Reduces the balance by the specified amount if sufficient funds are available.
getBalance(): number — Returns the current balance.
Example 1: Input: const account = createAccountManager(100); account.deposit(50); account.getBalance(); Output: 150 Explanation: The initial balance was 100, and after depositing 50, it became 150.Example 2: Input: account.withdraw(30); account.getBalance(); Output: 120 Explanation: After withdrawing 30, the balance updates to 120.Constraints:
The initialBalance is a non-negative integer.
Withdrawals cannot exceed the current balance.
codingHardconcurrency#2
2. [OA] Event Loop — Implement a JavaScript function to simulate the behavior of Coinbase’s frontend event loop.
In the context of synchronous and asynchronous operations, understanding how the event loop handles tasks is crucial for performance in high-frequency trading platforms like Coinbase. Problem Statement: You need to implement a function simulateEventLoop(tasks: Array<Promise<void>>): void that takes an array of promises representing asynchronous tasks and executes them in a way that reflects the behavior of the event loop. Ensure that any tasks scheduled in the event loop (using setTimeout or similar) are executed only after the current stack is clear.
simulateEventLoop(tasks: Array<Promise<void>>): void — Simulates the event loop and executes tasks in order.
Example 1: Input: simulateEventLoop([Promise.resolve(), new Promise((res) => setTimeout(res, 100)), Promise.resolve()]) Output: Executed (in order: resolve, wait, resolve) Explanation: The first promise is resolved immediately, then the second waits for 100ms before executing, followed by the final promise.Example 2: Input: simulateEventLoop([new Promise((res) => setTimeout(res, 50)), Promise.resolve(), new Promise((res) => setTimeout(res, 20))]) Output: Executed (in order: wait 50ms, resolve, wait 20ms)Constraints:
1 <= tasks.length <= 10^4
Each task will either be a resolved promise or a promise that resolves after a timeout.
system designSeniorapi design#3
3. [OA] Client-side Router — Design a basic client-side router for the Coinbase web application.
With the dynamic nature of financial applications, a smooth client-side routing experience is integral for user retention on Coinbase. Problem Statement: You need to implement a class ClientRouter that manages different routes in a single-page application. Users will navigate between different components based on the URL without refreshing the page.
addRoute(path: string, component: Function): void — Adds a new route along with its corresponding component.
navigate(path: string): void — Navigates to the given path and renders the associated component.
getCurrentPath(): string — Returns the current path the user is on.
Example 1: Input: const router = new ClientRouter(); router.addRoute('/home', HomeComponent); router.navigate('/home'); Output: Rendered HomeComponent Explanation: After navigating to /home, the associated component is rendered.Example 2: Input: router.addRoute('/about', AboutComponent); router.navigate('/about'); Output: Rendered AboutComponentConstraints:
All paths are unique and in the format of a valid URL path.
system designSeniorapi design#4
4. [OA] Virtual DOM — Design a lightweight Virtual DOM to improve rendering performance on Coinbase’s web interface.
Given the dynamic nature of cryptocurrency data, efficiently updating the UI is essential in the Coinbase platform. A Virtual DOM can help minimize direct manipulation of the actual DOM. Problem Statement: You need to implement a class VirtualDOM that can create, update, and render a lightweight representation of a real DOM. This is vital to reduce expensive layout recalculations and improve responsiveness.
createElement(tag: string, props: Object, children: Array<VirtualNode>): VirtualNode — Create a new Virtual Node.
update(oldNode: VirtualNode, newNode: VirtualNode): VirtualNode — Update an old node to match a new one and return the updated Virtual Node.
render(node: VirtualNode): HTMLElement — Convert a Virtual Node back into a real DOM HTMLElement.