706. Design HashMap 發表於 2023-02-13 | 分類於 leetcode problemsolution1234567891011121314151617181920212223242526272829class 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); */