Skip to content

Commit

Permalink
Create Design-Hashmap.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinjan-saha authored Oct 5, 2023
1 parent 5ae77ed commit 25849ad
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions codes/cpp/Design-Hashmap.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
class MyHashMap {
public:
vector<int> vec;
int sz;

MyHashMap() {
sz = 1e6+1;

vec.resize(sz);

fill(vec.begin(), vec.end(), -1);
}

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

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

void remove(int key) {
vec[key] =-1;
}
};

0 comments on commit 25849ad

Please sign in to comment.