Design First-Fit and Best-Fit Memory Allocation
Company: OpenAI
Role: Software Engineer
Category: Software Engineering Fundamentals
Difficulty: medium
Interview Round: Technical Screen
Overview: Design a heap allocator over one contiguous region with first-fit and best-fit placement, block splitting, and coalescing of adjacent free blocks. Frees take opaque handles, so a forged handle, or a stale one whose byte range now belongs to a newer allocation, must be rejected without changing any state. Covers exact-fit and exhaustion cases, fragmentation (total free vs largest block), segregated free lists, alignment, concurrency, and tests that expose corruption.
Read the full OpenAI Software Engineer interview experience this question came from