解題說明
C++ 解法
複雜度分析
虛擬碼
1. Initialize array mem[0..n-1] = 0 (all free) 2. allocate(size, mID): a. Scan left to right, count consecutive free cells b. When count reaches size, mark those cells with mID c. Return starting index, or -1 if not found 3. freeMemory(mID): a. Scan array, set all cells with mID to 0 b. Return count of freed cells