-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from Shinjan-saha/main
Added Design-Hashmap a Problem From Leetcode Solved in C++.
- Loading branch information
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
}; |