1 parent 7c309f0 commit 8bfb0b6Copy full SHA for 8bfb0b6
1 file changed
javascript/0706-design-hashmap.js
@@ -0,0 +1,37 @@
1
+var MyHashMap = function () {
2
+ this.map = new Map();
3
+};
4
+
5
+/**
6
+ * @param {number} key
7
+ * @param {number} value
8
+ * @return {void}
9
+ */
10
+MyHashMap.prototype.put = function (key, value) {
11
+ this.map.set(key, value);
12
13
14
15
16
+ * @return {number}
17
18
+MyHashMap.prototype.get = function (key) {
19
+ const val = this.map.get(key);
20
+ return val !== undefined ? val : -1;
21
22
23
24
25
26
27
+MyHashMap.prototype.remove = function (key) {
28
+ this.map.delete(key);
29
30
31
32
+ * Your MyHashMap object will be instantiated and called as such:
33
+ * var obj = new MyHashMap()
34
+ * obj.put(key,value)
35
+ * var param_2 = obj.get(key)
36
+ * obj.remove(key)
37
0 commit comments