problem379

package
v1.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2020 License: MIT Imports: 0 Imported by: 0

README

< Previous                  Next >

379. Design Phone Directory (Medium)

Design a Phone Directory which supports the following operations:

  1. get: Provide a number which is not assigned to anyone.
  2. check: Check if a number is available or not.
  3. release: Recycle or release a number.

Example:

// Init a phone directory containing a total of 3 numbers: 0, 1, and 2.
PhoneDirectory directory = new PhoneDirectory(3);

// It can return any available phone number. Here we assume it returns 0. directory.get();

// Assume it returns 1. directory.get();

// The number 2 is available, so return true. directory.check(2);

// It returns 2, the only number that is left. directory.get();

// The number 2 is no longer available, so return false. directory.check(2);

// Release number 2 back to the pool. directory.release(2);

// Number 2 is available again, return true. directory.check(2);

[Design] [Linked List]

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL