From 25849ad0b2619177cbf1341dfe4f6c55f36e66a5 Mon Sep 17 00:00:00 2001 From: Shinjan saha <116014977+Shinjan-saha@users.noreply.github.com> Date: Thu, 5 Oct 2023 18:59:34 +0530 Subject: [PATCH] Create Design-Hashmap.cpp --- codes/cpp/Design-Hashmap.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 codes/cpp/Design-Hashmap.cpp 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; + } +};