Design Memory Allocator

Design a memory allocator managing n contiguous units. Support allocating a block of size consecutive free units with a given ID (returning the start index), and freeing all units with a given ID (returning the count).

Examples
Input: [["MemoryAllocator","allocate","allocate","allocate","free","allocate"],[[10],[1,1],[1,2],[1,3],[2],[3,4]]]
Output: [null,0,1,2,1,3]
Hints

Design Memory Allocator

Design a memory allocator managing n contiguous units. Support allocating a block of `size` consecutive free units with a given ID (returning the start index), and freeing all units with a given ID (returning the count).