706. Design HashMap

problem

solution

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class MyHashMap {
private:
vector<int> vec;
public:
MyHashMap() {
vec = vector<int>(1000001,-1);
}

void put(int key, int value) {
vec[key] = value;
}

int get(int key) {
return vec[key];

}

void remove(int key) {
vec[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);
*/