Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AvraamMavridis/9d3e6f2639dd55ee07daa24d8519b1b7 to your computer and use it in GitHub Desktop.
Save AvraamMavridis/9d3e6f2639dd55ee07daa24d8519b1b7 to your computer and use it in GitHub Desktop.
Build a data structure that implements the following 3 functions:
- set(key, value) → sets key and value in the data structure and returns nothing.
- get(key) → returns the value that was set for this key (null if doesn’t exist)
- set_all(value) → sets the value for all keys that are in the data structure. Returns nothing.
The catch is that each of the functions should run in constant time - O(1).
Can assume in-memory simple single thread process.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment