Skip to content

Instantly share code, notes, and snippets.

@haydnba
Last active May 11, 2021 12:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haydnba/b76703d2b4f76f589a5c873a5c814180 to your computer and use it in GitHub Desktop.
Save haydnba/b76703d2b4f76f589a5c873a5c814180 to your computer and use it in GitHub Desktop.
Alon's tech test
Please write a data structure which has the following method:
1. setValue (index, value) - set the structure at `index` to `value`
2. getValue (index) - get the value of the data structure at `index`
3. setAll (value) - set all indices in the data structure to `value`
please implement all method in O(1) runtime.
Expected behaviour:
setValue("a", 7)
setValue("j", 8)
getValue("a") -> 7
getValue("j") -> 8
setAll(8)
getValue("a") -> 8
getValue("j") -> 8
setValue("j", 4)
getValue("a") -> 8
getValue("j") -> 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment