diff --git a/09. Hashing/5. design_hash_map.cpp b/09. Hashing/5. design_hash_map.cpp new file mode 100644 index 00000000..9860a2da --- /dev/null +++ b/09. Hashing/5. design_hash_map.cpp @@ -0,0 +1,27 @@ +class MyHashMap { + vector mapArray; +public: + MyHashMap() { + mapArray=vector(1000001,-1); + } + + void put(int key, int value) { + mapArray[key]=value; + } + + int get(int key) { + return mapArray[key]; + } + + void remove(int key) { + mapArray[key]=-1; + } +}; + +/** + * Your MyHashMap object will be instantiated and called as such: + * MyHashMap* obj = new MyHashMap(); + * obj->put(key,value); + * int param_2 = obj->get(key); + * obj->remove(key); + */