Design an ID Allocator (Assign and Release)

Given an integer N, design an ID allocator with two functions:

  1. assign(): return an unused ID in the range [0, N-1], or -1 if none is available. The original problem does not restrict the ord...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: