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
system designSeniorapi design#1
1. [OA] Service Health Monitor — Design a system to monitor and report service health at Coinbase
With numerous microservices, it’s crucial for Coinbase to have a robust service health monitoring system to ensure uptime and reliability. Problem Statement: Design a ServiceHealthMonitor class that can check the health of services and report their status. This monitor should allow dynamic addition of services and periodic health checks. Method Signatures:
def add_service(name: str, check_func: Callable[[], bool]) -> None: - Adds a service to be monitored along with its health check function.
def check_health() -> Dict[str, bool]: - Checks the health of all services and returns a dictionary mapping service names to health status.
def report_status() -> None: - Reports the health status of the services, ideally logging or sending alerts for any down services.
Example 1: Input: add_service('auth_service', lambda: True) Output: None Explanation: Adds the auth_service with a successful health check.Example 2: Input: check_health() Output: {'auth_service': True} Explanation: Returns the health status of the services.Constraints:
1 <= name.length <= 50
The number of services monitored will not exceed 100.
system designSeniorcaching#2
2. [OA] LRU Cache — Design an efficient caching layer for API responses at Coinbase
To improve performance and reduce latency, Coinbase needs a sophisticated caching mechanism for frequently accessed API responses. Problem Statement: Design and implement an LRUCache class that supports the following operations: get and put. The operations should be efficient enough to meet the demands of high-frequency API access. Method Signatures:
def get(key: int) -> int: - Returns the value of the key if the key exists, otherwise returns -1.
def put(key: int, value: int) -> None: - Updates the value of the key if the key exists and if it doesn't, adds the key-value pair to the cache. When the cache reaches its capacity, it should invalidate the least recently used item before inserting a new item.
Example 1: Input: put(1, 1) Output: None Explanation: Cache updated with key 1 and value 1.Example 2: Input: get(1) Output: 1 Explanation: Returns the cached value 1 for key 1.Constraints:
capacity must be a positive integer.
The number of calls to get and put will not exceed 10000.
Coinbase aims to maintain lightweight Docker images for faster deployment and reduced bandwidth usage. Problem Statement: Your task is to optimize a given Dockerfile used to build a service image. The goal is to minimize the image size while ensuring that all dependencies are available and the application runs as expected. Method Signatures:
def optimize_dockerfile(base_image: str, packages: List[str]) -> str: - Returns an optimized Dockerfile as a string.
Example 1: Input: optimize_dockerfile('python:3.9-slim', ['flask', 'requests']) Output: "FROM python:3.9-slim RUN pip install --no-cache-dir flask requests" Explanation: Returns an optimized Dockerfile using slim image and no-cache for pip installations.Example 2: Input: optimize_dockerfile('node:14', ['express', 'body-parser']) Output: "FROM node:14 RUN npm install --production" Explanation: This avoids dev dependencies to keep the image size smaller.Constraints:
1 <= base_image.length <= 50
1 <= packages.length <= 20 and each package name is at most 30 characters long.
Coinbase relies on efficiently managing deployment pipelines for its microservices architecture to ensure rapid delivery of new features and fixes. Problem Statement: You are tasked to create a script that automates the CI/CD pipeline for a microservice application. The script should handle tasks such as building Docker images, running tests, and deploying to a specified environment. You should also ensure the script can roll back to the previous version in case of failure. Method Signatures:
def build_image(service_name: str) -> None: - Builds the Docker image for the service.
def run_tests(service_name: str) -> bool: - Runs tests for the service and returns True if all tests pass.
def deploy(service_name: str, environment: str) -> None: - Deploys the service to the specified environment.
def rollback(service_name: str) -> None: - Rolls back the deployment to the previous version.
Example 1: Input: build_image('auth_service') Output: None Explanation: This should build the Docker image for the auth service.Example 2: Input: run_tests('auth_service') Output: True Explanation: This indicates that all tests for the auth service passed.Constraints:
1 <= service_name.length <= 100
environment must be one of the strings: 'staging', 'production', 'development'.