Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions 09. Hashing/5. design_hash_map.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
class MyHashMap {
vector <int> mapArray;
public:
MyHashMap() {
mapArray=vector<int>(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);
*/