OpenAI

Verified interview challenge

Design a memory allocator

Allocate and release memory while keeping track of the free space left between live allocations.

Unlock with Full Access

The challenge

Simulate a fixed block of memory that receives allocation and release requests. Your allocator must choose the correct available region, recognise invalid frees and combine adjacent free regions. Repeated allocations can leave many small gaps, so the search behaviour matters as the workload grows.

A simulation of memory management
You work with numbered addresses and operations. The task does not require managing the process's actual memory.

What you'll practise

  • Allocation tracking

    Distinguish live allocations from free intervals and preserve the requested placement behaviour.

  • Fragmentation and reuse

    Make released space available again, including neighbouring free regions.

  • Search performance

    Keep allocation requests practical when the memory contains many gaps.

Your coding workspacePreview
solution.pyPython 3.13
def memory_allocator_results(
    capacity, operations
):
    # Your implementation goes here
    pass
Test cases

Run your code to see results.

Full instructions, starter code and test cases included with Full Access.