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...
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 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 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 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...
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...
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 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...
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...
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 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: (...
Implement in-memory KV store with serialization
Implement an in-memory key-value store in Python that supports setting and retrieving values and can serialize and deserialize the entire store. Defin...
Implement a GPU credit manager
Implement a GPU credit manager for a compute cluster. Each user has a nonnegative credit balance that can be increased (grantCredits(user, amount)), c...
Find earliest supporting dependency version
Question Given a list of dependency versions (e.g. [103.003.02, 103.003.03, 203.003.02]) and a black-box API isSupported(v), design an algorithm to fi...
Merge overlapping intervals
Question LeetCode 56. Merge Intervals – Given a collection of intervals, merge all overlapping intervals into one and return an array of the non-overl...
Implement persistent key-value store
Question Design and implement an in-memory key-value store supporting set(key, value), get(key), shutdown() that flushes all data as bytes to a medium...
Manage GPU Credits with Expiration
Question Implement a GPU credit manager supporting out-of-order operations: API add_credit(id, amount, timestamp, expiration) // adds ‘amount’ credit...
Merge overlapping time intervals efficiently
Given a list of closed intervals [start, end] with 0 <= start <= end, merge all intervals that overlap or touch and return a minimal set of non-overla...