diff --git a/README.md b/README.md index 953596d..681dd3b 100644 --- a/README.md +++ b/README.md @@ -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)
[Medium](https://sakshi8699.medium.com/981-time-based-key-value-store-python-65bd81742818)| [Java](./codes/java/timebasedkeyvaluestore.java)
[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)
[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) | diff --git a/codes/cpp/Design-Hashmap.cpp b/codes/cpp/Design-Hashmap.cpp new file mode 100644 index 0000000..5ba68ad --- /dev/null +++ b/codes/cpp/Design-Hashmap.cpp @@ -0,0 +1,25 @@ +class MyHashMap { +public: + vector 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; + } +};