Algorithm · Okta · Medium
Requirements You are given an array M representing memory, where each cell is either 0 (free) or 1 (allocated). You also receive a list of commands L, where each command is a two-element list. Allocate: L[i][0] == 0. L[i][1] is the number of contiguous cells requested. Find the leftmost block of free cells in M that is at least that size, mark those cells as 1, and assign the allocation a unique ID from an atomic, strictly increasing counter. Return the assigned ID. If no…
Checking your access…