OpenAI Coding & Algorithms Interview Questions
Master your tech interview with our curated database of real questions from top companies.
Implement in-memory DB querying
Question Implement an in-memory database that supports: 1. Querying the whole table and returning only selected columns (projection). 2. Adding WHERE ...
Identify Bugs in Python Script for User Assignment
Scenario A simple Python script assigns users to experiment groups and triggers the free-trial offer. Question Inspect the script and list any bugs or...
Find earliest supporting version under constraints
You are given version strings formatted as {major}.{minor}.{patch}, e.g., "103.003.03". Each version either supports a feature or not. You may call is...
Implement credit ledger with out-of-order timestamps
Problem You are implementing a GPU credit ledger that supports adding credits, charging credits, and querying balances. Requests can arrive in any tim...
Implement an in-memory SQL-like table
Problem Implement a simple in-memory database for one table. All values are strings. Each row is identified by a rowKey (string). Each row contains co...
Implement map serialization and deserialization
You are given an in-memory map (dictionary) from strings to strings. Implement two functions: - string serialize(map<string, string> m) - map<string, ...
Implement a persistent sharded key-value store
Problem Implement a simple key–value store that persists data on disk. You must store the data in fixed-size shards, where each shard is saved in one ...
Implement IPv4 iterators and CIDR expansion
Problem: IPv4 Iterators and CIDR Expansion You are implementing utilities to iterate over IPv4 addresses. An IPv4 address is in dotted-decimal form: A...
Simulate turn-based monster team battle
Design an object-oriented model and implement the core battle logic for a turn-based fight between two teams of monsters. The system should simulate t...
Compute time to infect all cells
You are given an n × m grid representing people in a city. - Each cell is either infected (1) or healthy (0). - Two cells are neighbors if they share ...
Design a persistent key-value store
Design and implement an in-memory key-value store with a 'medium' layer that serializes the store to bytes for persistence. Provide four functions: se...
Implement expiring credit ledger
Implement an expiring-credit ledger that supports out-of-order events. Expose three functions with the following semantics: - add_credit(id, amount, t...
Implement compile-time function type verification
Implement a C++20 compile-time utility to verify whether a callable matches a target function type. Requirements: create a primary template is_callabl...
Implement GPU credit ledger
You manage a GPU pool with per-tenant credits. Given a list/stream of events where each event adjusts a tenant’s credit balance by a signed integer (p...
Implement KV store and plan type conversions
Part 1 — Versioned key-value store: Implement a data structure with set(key, value, t) and get_at(key, t) that returns the value for key whose timesta...
Design a parser for a hypothetical language
You are given a set of syntax rules for a hypothetical programming language written in BNF/EBNF. Design data structures and algorithms that: ( 1) pars...
Implement a Simulated Memory Allocator
Implement a simulated memory allocator that supports allocate(size) and free(ptr) operations analogous to malloc and free. Treat memory as a contiguou...
Optimize C++ Performance with Provided Concurrency
Given a C++ codebase where threading components (threads, work queues, and synchronization primitives) are already provided, profile and optimize the ...
Implement KV store serialization
Implement serialization and deserialization for an in‑memory key‑value store to and from a contiguous bytes buffer. Keys are UTF‑8 strings; values may...
Implement an expiring GPU-credit manager
Implement an expiring GPU-credit manager for a cloud provider. Each user receives credit grants with an amount and an expiration timestamp. Support: (...