Last active
May 11, 2021 12:23
-
-
Save haydnba/b76703d2b4f76f589a5c873a5c814180 to your computer and use it in GitHub Desktop.
Alon's tech test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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