2
vector<vector<pair<int, int>>> map;3
const int size = 10000;6
/** Initialize your data structure here. */11
/** value will always be non-negative. */12
void put(int key, int value) {13
int index = key % size;14
vector<pair<int, int>> &row = map[index];15
for (auto iter = row.begin(); iter != row.end(); iter++) {16
if (iter->first == key) {21
row.push_back(make_pair(key, value));24
/** Returns the value to which the specified key is mapped, or -1 if this map25
* contains no mapping for the key */27
int index = key % size;28
vector<pair<int, int>> &row = map[index];29
for (auto iter = row.begin(); iter != row.end(); iter++) {30
if (iter->first == key) {37
/** Removes the mapping of the specified value key if this map contains a38
* mapping for the key */39
void remove(int key) {40
int index = key % size;41
vector<pair<int, int>> &row = map[index];42
for (auto iter = row.begin(); iter != row.end(); iter++) {43
if (iter->first == key) {52
* Your MyHashMap object will be instantiated and called as such:53
* MyHashMap* obj = new MyHashMap();54
* obj->put(key,value);55
* int param_2 = obj->get(key);