Category: Trie-based system design problem# System Design Questions - OpenAI A collection of commonly asked system design questions from OpenAI interviews.Input: Given input Output: Computed result
codingHardVerified Question#2
2. Count Machines In A Tree
Category: Tree coding problemYou are given a tree-structured network of machines where each node represents a machine. Machines can only communicate with their parent and...Input: String Output: Computed result
codingMediumVerified Question#3
3. Implement cd Command
Category: Algorithm coding problemImplement a simplified version of the Unix cd command. Given a current directory path and a relative destination path, return the final absolute...Input: Given input Output: Computed result
codingMediumVerified Question#4
4. Largest Subgrid
Category: Grid/matrix coding problemYou are given a 2D grid of non-negative integers and a maximum sum constraint. Find the largest size of a square sub-grid such that all...Input: 2D grid Output: Integer
codingHardVerified Question#5
5. Memory Allocator
Category: Linked list coding problem# Memory Allocator Design a memory allocator that manages a contiguous block of memory. Implement malloc and free operations with efficient...Input: Linked list Output: Computed result
codingHardVerified Question#6
6. Toy Language Type Inference
Category: String coding problemImplement a type system for a toy programming language that supports primitives, tuples, and generics. Your task is to represent types and infer...Input: List Output: Computed result
codingMediumVerified Question#7
7. Virus Spread
Category: Grid/matrix coding problemSimulate the spread of a virus through a grid. Each cell can be in one of three states: healthy, infected, or immune. *This is similar to a leetcode...Input: 2D grid Output: Integer
codingMediumVerified Question#8
8. Bot-Enabled Messaging System
Category: String coding problemYou are building a chat system that supports human users and automated bots. Messages are added to a channel log and may trigger bot responses. The...Input: List Output: Computed result
codingHardVerified Question#9
9. Connection Tracker
Category: Algorithm coding problemDesign a social network system that tracks follow relationships between users and preserves a full history through snapshots. The system allows...Input: List Output: Computed result
codingMediumVerified Question#10
10. GPU Credit Ledger
Category: String coding problemYou are designing a system to manage GPU credits. Each credit grant is valid during a specific time window. Events may arrive out of chronological...Input: String Output: Computed result
codingMediumVerified Question#11
11. GPU Credit Manager
Category: String coding problemYou are designing a system to manage GPU credits. Each credit grant is valid during a specific time window. Events may arrive out of chronological...Input: String Output: Computed result
codingHardVerified Question#12
12. In-Memory SQL Engine
Category: String coding problemDesign an in-memory SQL database that supports creating tables, inserting rows with automatic type inference, and querying with filtering and sorting.Input: List Output: Computed result
codingHardVerified Question#13
13. Persistent Key-Value Store
Category: Trie-based coding problemYou are designing a persistent key-value store that serializes its state to a binary storage medium. Native serialization (e.g., JSON, pickle,...Input: Array Output: Computed result
codingHardVerified Question#14
14. Shard Rebalancer
Category: String coding problemYou are implementing a shard management system for a distributed key-value store. Each shard is identified by a string and covers a contiguous range...Input: String Output: Computed result
codingHardVerified Question#15
15. IP Address Iterator
Category: String coding problemEvery device on the public internet is identified by an IPv4 address written in dotted-decimal notation as "A.B.C.D", where each octet is an...Input: String Output: Computed result
codingMediumVerified Question#16
16. Version Support Finder
Category: Binary search coding problemA software company maintains a sorted list of version strings in ascending chronological order. A critical feature was introduced in one version, and...Input: List Output: Computed result
codingMediumVerified Question#17
17. Monster Battle Simulator
Category: String coding problemSimulate a deterministic, turn-based battle between two ordered teams of monsters. Execute the fight step by step and produce a chronological battle...Input: List Output: Computed result
codingMediumVerified Question#18
18. Distributed Tree Messaging
Category: Tree coding problemYou are implementing a message-passing protocol for a distributed system organized as a rooted n-ary tree. Each node represents a machine and...Input: List Output: Printed output
system designSeniorapi design#1
1. [OA] API Design for Model Training — Design an API for model training at OpenAI
OpenAI frequently trains and fine-tunes machine learning models, requiring an organized API to serve these requests efficiently. Problem Statement: Design a class named ModelTrainingAPI that allows clients to submit training jobs, check their progress, and retrieve results once completed. - submit_training_job(model_id: str, data: Any) -> str: Submit a new training job and return the job ID. - check_job_status(job_id: str) -> str: Retrieve the current status of a training job. - get_job_result(job_id: str) -> Any: Retrieve the results of a completed job. Example 1: Input: Submit a training job with a model ID and training data. Output: Returns a unique job ID to track. Explanation: The API facilitates the model training workflow by providing necessary actions. Constraints: - The API should handle up to 500 concurrent training jobs. - Training jobs should support data sizes up to 10GB.
system designMediumapi design#2
2. [OA] Distributed Config Manager — Design a configuration manager for OpenAI's microservices
OpenAI's microservices architecture requires a centralized configuration management system to ensure consistent settings across various services. Problem Statement: Design a class named ConfigManager, which handles loading and retrieving configurations from a key-value store. The class should support watching for configuration changes and notify services when updates occur. - load_config() - Load configurations from a given source. - get_config(key: str) -> str - Retrieve the value for the provided key. - watch_config(key: str, callback: Callable) - Register a callback to be called when the configuration for the specified key changes. Example 1: Input: Load configuration from a JSON file. Output: Key-value pairs are stored internally. Explanation: The ConfigManager can load configurations on startup and provide them to other services. Constraints: - The key store should support at least 1000 key-value pairs. - Must provide thread-safe access to configuration values.
codingHardinfra#3
3. [OA] Terraform State Management — Manage shared state in a team environment
In the OpenAI cloud infrastructure, multiple teams often use Terraform to provision resources, which requires effective state management strategies. Problem Statement: Explain how to handle shared Terraform state using remote backends while ensuring locking mechanisms are in place to prevent race conditions. Also, provide sample Terraform configurations for best practices. Example 1: Input: A scenario where multiple developers are trying to apply terraform apply simultaneously. Output: Configuration using Terraform's remote backend mechanism with locking enabled. Explanation: By using a remote backend such as AWS S3 with DynamoDB for locking, race conditions can be avoided. Constraints: - The solution must allow for multiple concurrent developers. - Must demonstrate a locking mechanism. - Must not lose state data during operations.
codingHardinfra#4
4. [OA] Dockerfile Optimization — Optimize the Docker build for an OpenAI microservice
OpenAI deploys its machine learning models with microservices in Docker containers that need efficient build processes. Problem Statement: You are tasked to optimize a given Dockerfile to reduce the build time without increasing the final image size. The Dockerfile uses multiple layers and redundancies that slow down the build process. Your goal is to create an optimized version that minimizes the number of layers while still maintaining functionality. Example 1: Input: Dockerfile containing multiple RUN and COPY commands. Output: Optimized Dockerfile using fewer layers and best practices. Explanation: By combining RUN commands and leveraging cache efficiency, the optimized version reduces build time. Constraints: - The base image should remain the same. - All dependencies must still be installed. - The final image size should not exceed the original image size by more than 10%.