Skip to content

Commit

Permalink
Merge pull request #65 from Shinjan-saha/main
Browse files Browse the repository at this point in the history
Added  Design-Hashmap a Problem From Leetcode  Solved in C++.
  • Loading branch information
Google-DSC-TMSL authored Oct 12, 2023
2 parents 5ae77ed + 35b1d45 commit 4fe87cb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
| Time Based Key Value Store | [LeetCode](https://leetcode.com/problems/time-based-key-value-store/) | [Youtube](https://www.youtube.com/watch?v=fu2cD_6E8Hw)<br> [Medium](https://sakshi8699.medium.com/981-time-based-key-value-store-python-65bd81742818)| [Java](./codes/java/timebasedkeyvaluestore.java)<br> [Python](./codes/python/timebasedkeyvaluestore.py) |
| Longest Common Substring | [GFG](https://www.geeksforgeeks.org/longest-common-substring-dp-29/) | [Youtube](https://www.youtube.com/watch?v=_wP9mWNPL5w&t=689s) | [Java](./codes/java/LongestCommonSubstring.java)
| House Robber II | [LeetCode](https://leetcode.com/problems/house-robber-ii/) | [Youtube](https://www.youtube.com/watch?v=3WaxQMELSkw) | [Java](./codes/java/HouseRobberII.java) |
| Design Hashmap | [LeetCode](https://leetcode.com/problems/design-hashmap/) | [Youtube](https://youtu.be/Xt4TuW31rtc?si=lEAxCq8KEhg45AA1) | [C++](./codes/cpp/Design-Hashmap.cpp) |
| Minimum Swaps To Make Sequences Increasing | [LeetCode](https://leetcode.com/problems/minimum-swaps-to-make-sequences-increasing/) | [Youtube](https://www.youtube.com/watch?v=IeT9Qz_vqHo) | [Java](./codes/java/minimumswapstomakesequencesincreasing.java)<br> [C++](./codes/cpp/minimumswapstomakesequencesincreasing.cpp) |
| Find Kth Bit in Nth Binary String | [LeetCode](https://leetcode.com/problems/find-kth-bit-in-nth-binary-string/) | [Youtube](https://www.youtube.com/watch?v=34QYE5HAFy4) | [Java](./codes/java/KthBitNthBinaryString.java)
| Set Matrix Zeros | [LeetCode](https://leetcode.com/problems/set-matrix-zeroes/) | [Youtube](https://www.youtube.com/watch?v=M65xBewcqcI) | [Java](./codes/java/setmatrixzeros.java) |
Expand Down
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 4fe87cb

Please sign in to comment.